高分求救,大虾们帮帮忙那,谢了!
这是一个用c写的自动化方面的程序。要求用用四阶(定步长)龙格--库塔法求解一个问题。
那些子程序应该没有问题,但就是不能运行(编译已通过)。不知道为什么,还有请大家推荐一个好的c编译软件。现在用的tc觉着不好。。
#define Max(a,b) (a>b)?a:b
#define BKLEFT 50
#define BKTOP 50
#define BKRIGHT 559
#define BKBOTTOM 419
#define LASTLI 155
#define LASTTP 410
#define LASTRT 470
#define LASTBM 445
#define ORGX BKLEFT+70
#define ORGY BKBOTTOM-55
#define XLEN 380
#define YLEN 310
#define FACT 20
#define CODE_NUM 30
#define item_width 5
#define space 4
#include <alloc.h>
#include <fcntl.h>
#include <graphics.h>
#include <io.h>
#include <process.h>
#include <dos.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <string.h>
#include <bios.h>
#define HAVEGRID 1
#define NOGRID 0
#define AUTODIV 1
#define MANULDIV 0
#define FIRSTTIME 0
#define NOTFIRST 1
#define MAXNUIT 15
#define MAXTITLE 40
#define VerySmall 1.0e-10
void win(int x,int y,int bkcolor,int color,char *content[],int chinese);
void inverse();
extern void outchinese(unsigned char text[],int x,int y,int color);
void output();
int matrix(int n);
extern float dscanf(int x0,int y0,int x1,int y1,int code_num);
int init_input();
int input();
int out_plot();
void sfz3();
int n,n1,q3,n0,n2,n3,n4,m,l,i,i1,e1,g1,q2,xx,j,k1,all_lines;
int n5,n6,n7,n8,order,various,length[2];
float zhi,q1,t,t1,t2;
float a[20][20],b[20],c[20],d[20][20],p[10][10],
f[20][20],g[20][20],s[20][20],r[20][20],v[20],
y[20],e[20][20],ye[200],te[40];
float h[7],lk[10][10],q[7][7],z[7];
char outfile[80];
double *xdata,*ydata;
extern float p[10][10];
void main()
{
int gdriver,gmode,ErrorCode;
gdriver=DETECT;
initgraph(&gdriver,&gmode,"");
ErrorCode = graphresult();
if( ErrorCode != grOk ){ /* Error occured during init */
printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) );
exit( 1 );
}
init_input();
input();
matrix(n);
for(i=1;i<=n;i++)
p[i][n+1]=p[i][0];
sfz3();
output();
spawnl(P_OVERLAY,"yfzMENU.EXE",NULL);
}
int init_input()
{
char code[10][12];
int ALL_CODES=9;
int order=11;
int CODES_LENGHT=8;
int x0,y0,item,old_item,key;
int step=0;
int offset[2]={90,45};
int length[2];
float x[30];
char *init[]={"状态变量初值",
"x[1]= \0",
"x[2]=",
"x[3]=",
"x[4]=",
"x[5]=",
"x[6]=",
"x[7]=",
"x[8]=",
"\0",};
char *content[]={"微分方程参数",
"仿真时间 \0",
"计算步长",
"输出点数",
"输出变量数",
"输出变量号",
"输出变量号",
"输出变量号",
"输出文件名",
"\0",};
char *help1[]={"↑↓:改变","\0"};
char *help2[]={"回车:确定","\0"};
char *help3[]={"F5:退出","\0"};
char *warning[2]={"退出程序吗?(y/n)","\0"};
for(j=0;j<=ALL_CODES;j++)
code[j][0]='\0';
length[0]=strlen(content[1]);
length[1]=strlen(init[1]);
do
{
item=old_item=0;
for(j=0;j<=ALL_CODES;j++)
code[j][0]='\0';
if(step==1)
{
if(order>0&&order<9)
{
strcpy(init[order+1],"\0");
}
ALL_CODES=order;
x0=(getmaxx()-(strlen(init[i])+2)*8-2)/2;
y0=(getmaxy()-((ALL_CODES+1)*20+4))/2;
cleardevice();
setbkcolor(BLACK);
win(500,160,DARKGRAY,WHITE,help1,1);
win(500,240,DARKGRAY,WHITE,help2,1);
win(500,320,DARKGRAY,WHITE,help3,1);
win(x0,y0,LIGHTGRAY,BLACK,init,0);
}
else if(step==0)
{
ALL_CODES=8;
x0=(getmaxx()-(strlen(content[1]+2)*8-2))/2;
y0=(getmaxy()-((3+1)*20+4))/2;
cleardevice();
setbkcolor(BLACK);
win(500,160,DARKGRAY,WHITE,help1,1);
win(500,240,DARKGRAY,WHITE,help2,1);
win(500,320,DARKGRAY,WHITE,help3,1);
win(x0,y0,LIGHTGRAY,BLACK,content,1);
}
j=0;
do
{
if(item!=old_item)
{
setfillstyle(SOLID_FILL,RED);
bar(x0+8+offset[step],y0+(item+1)*20-3,x0+(length[step]+2)*8-2-6,y0+(item+2)*20-6);
setcolor(YELLOW);
outtextxy(x0+8+offset[step]+2,y0+(item+1)*20+4,code[item]);
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar(x0=8+offset[step],y0+(old_item+1)*20-3,x0+(length[step]+2)*8-2-6,y0+(old_item+2)*20-6);
outtextxy(x0+8+offset[step]+2,y0+(old_item+1)*20+4,code[old_item]);
old_item=item;
}
else
{
setfillstyle(SOLID_FILL,RED);
bar(x0+8+offset[step],y0+(item+1)*20-3,x0+(length[step]+2)*8-2-6,y0+(item+2)*20-6);
setcolor(YELLOW);
outtextxy(x0+8+offset[step]+2,y0+(item+1)*20+4,code[item]);
}
key=bioskey(0);
if((key&0xff)==0)
key=key>>8;
else
{
key=key&0xff;
if(j<CODES_LENGHT&&((key>='0'&&key<='9')||key=='.'||key=='e'||key=='E'||key>='a'&&key<='z'||key>='A'&&key<='Z'||key=='-'))
{
j++;
code[item][j-1]=key;
code[item][j]='\0';
}
}
if((key==0x08)&&(j>0))
{
code[item][j-1]='\0';
j--;
}
if(key==0x48)
{
if(item==0)
item=ALL_CODES-1;
else
item--;
j=0;
}
if(key==0x50)
{ if(item==ALL_CODES-1)
item=0;
else
item++;
j=0;
}
if(key==0x3f)
{
win(40,420,DARKGRAY,WHITE,warning,1);
key=bioskey(0);
if(key==0x1559||key==0x1579)
{
cleardevice();
exit(0);
}
else
{
setfillstyle(SOLID_FILL,getbkcolor());
bar(40,410,340,450);
key=0;
}
}
if(key==13)
{
if(step==1)
{
for(i=0;i<order;i++)
x[i+1]=atof(code[i]);
bar(x0,y0-8,500,470);
step=-1;
return 1;
}
if(step==0)
{
t1=atof(code[0]);
t2=atof(code[1]);
n2=atoi(code[2]);
n0=atoi(code[3]);
n6=atoi(code[4]);
n7=atoi(code[5]);
n8=atoi(code[6]);
strcpy(outfile,code[7]);
step=1;
ALL_CODES=order;
setfillstyle(SOLID_FILL,BLACK);
bar(x0,y0-8,500,470);
}
}
}while(key!=13);
}while(step==0||step==1);
}