當前位置:首頁 » 編程語言 » c語言解微分方程組

c語言解微分方程組

發布時間: 2023-06-09 16:47:14

1. 用c語言實現分別用歐拉法和改進的歐拉法計算常微分方程:y'=-x*y^2 (x>=0且x<=3) ;y(0)=2,,可用vc6.0運行

// zifuchuan.cpp : Defines the entry point for the console application.
//
#include "stdio.h"
#include 「stdlib.h」
#define N 20
//#define exit 0
int length(char *p)
{
int i,count=0;
for(i=0;p[i]!='\0';i++)
count++;
return count;
}
void (char *p1,char *p2)
{
int i;
for(i=0;p2[i]!='\0';i++)
p1[i]=p2[i];
if(p1[i]!='\0')
p1[i]='\0';
printf("復制完成\n");
printf("%s\n",p1);
}
int compare(char *p1,char *p2)
{
int i,j;
for(i=0;p1[i]!='\0'||p2[i]!='\0';i++)
if(p1[i]!=p2[i])
{
j=p1[i]-p2[i];
return j;
}
return 0;
}
int main(int argc, char* argv[])
{
char p1[20],p2[20];
int e,f;
printf("請輸入字元串\n");
printf("請輸入字元串p1\n");
scanf("%s",p1);
printf("請輸入字元串p2\n");
scanf("%s",p2);
// printf("請輸入字元串p2\n");
// scanf("%s",p2);
while(1)
{
printf("----------1.求字元串長度----------\n");
printf("------------2.復制拷貝字元串----------\n");
printf("------------3.比較字元串------------\n");
printf("--------------4.退出程序--------------\n");
int choose;
printf("請選擇:");
scanf("%d",&choose);
switch(choose)
{
case 1:e=length(p1);printf("%d\n",e);break;
case 2:(p1,p2);break;
case 3:f=compare(p1,p2);printf("%d\n",f);break;
case 4:exit(0);
}
}
}

2. 微分方程 C語言

難度太大,不過可以找到的,不要為難別人

3. 運用C語言,龍格庫塔求解微分方程組

一下微分方程組,我加分 function df=ode45_fun(t,xyzuvw) %%注意小寫的v和大寫的V %常數(請修正) R_0=1; rho_0=1; beta=1; G=6.67 ..

4. C語言 經典R-K方法解微分方程 謝謝大家了,新手~~最好還寫點說明,非常感謝!!

#include<stdio.h>
/*
針對你給的問題
dy/dt=t/y
y(2.0)=1 2.0<=t<=2.6 h=0.2 怎麼輸入、輸出呢?

*/
double f(double x,double y)//這是你給的問題的函數t/y
{
return x/y;
}
void Runge_Kutta4(double y0,double x0,double h,double b)//四階的Runge_Kutta法
{
double y1;double k[4];int i=0;
while (1){
i++;
k[0]=f(x0,y0);
k[1]=f(x0+h/2.0,y0+h*k[0]/2.0);
k[2]=f(x0+h/2.0,y0+h*k[1]/2.0);
k[3]=f(x0+h,y0+h*k[2]);
y1=y0+h*(k[0]+2*k[1]+2*k[2]+k[3])/6.0;
printf("%d\t%f\t%f\n",i,x0+h,y1);//這里是C語言的輸出
//cout<<i<<'\t'<<x0+h<<'\t'<<y1<<'\n'; 這是C++語言的輸出
if(x0+2*h>=b)break;
y0=y1;x0=x0+h;
}
}

void main()
{
Runge_Kutta4(1.0,2.0,0.2,2.6);
}
結果:
1 2.200000 1.356505
2 2.400000 1.661361

全改C語言了 如有不明再問我吧
你的串號我已經記下,採納後我會幫你製作

熱點內容
pid演算法調速 發布:2025-02-13 21:20:31 瀏覽:686
腳本中new 發布:2025-02-13 21:00:11 瀏覽:741
什麼配置的筆記本電腦能玩神武 發布:2025-02-13 20:54:40 瀏覽:178
挑選雲伺服器需要注意什麼 發布:2025-02-13 20:53:31 瀏覽:98
加密滴膠卡 發布:2025-02-13 20:30:48 瀏覽:275
javalogin 發布:2025-02-13 20:25:48 瀏覽:427
智聯招聘無法上傳照片 發布:2025-02-13 20:16:03 瀏覽:529
python元素替換list 發布:2025-02-13 20:03:48 瀏覽:773
windows系統賬戶名和密碼是多少 發布:2025-02-13 20:03:02 瀏覽:531
我的世界帶有商店伺服器好嗎 發布:2025-02-13 20:02:50 瀏覽:616