标题:急求高手帮忙,这个程序不知怎么改正???
取消只看楼主
pdzshui
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-5-21
 问题点数:0 回复次数:1 
急求高手帮忙,这个程序不知怎么改正???

急求!!!!!!!!! #include"graphics.h" #include"stdio.h" float dt,T[100]={0},A[100]={0}, U[100][100],V[100]={0}, tf,u0,U9[100],C9[100], A9[100],Z9[100],K[100]={0},t; int i,mm,nn,q,m,n,k,m1,n9,I[100]={0}, J[100]={0},p[100]={0}; #include"math.h" main() { FILE *fp,*ft; char x[500]; float temp[17]; float time[503],v1[503],v2[503], v3[503],v4[503]; int gdriver=DETECT,gmode; registerbgidriver(EGAVGA_driver); initgraph(&gdriver,&gmode,"c:\\tc"); setbkcolor(15); fp=fopen("d:/tl/grid2in.txt","r"); ft=fopen("d:/tl/grid2out.txt","w"); fgets(x,sizeof(x),fp); sscanf(x,"%d %d %d %f %d",&mm,&nn, &q,&dt,&n9); for(i=0;i<=nn;i++) {fgets(x,sizeof(x),fp); sscanf(x,"%d",&p[i]); } for(i=1;i<=mm;i++) { fgets(x,sizeof(x),fp); sscanf(x,"%d %d %f %f",&I[i],&J[i], &T[i],&A[i]); } for(i=1;i<=nn-n9+1;i++) { fgets(x,sizeof(x),fp); sscanf(x,"%f %f %f %f",&Z9[i],&U9[i], &C9[i],&A9[i]); } fgets(x,sizeof(x),fp); sscanf(x,"%f %f",&tf,&u0); for(i=0;i<=q;i++) { for(t=0;t<=mm;t++) U[i][t]=0;} fprintf(ft,"----------------------------------------\n"); fprintf(ft,"NODE voltgage\n"); fprintf(ft,"-----------------------------------------\n"); fprintf(ft," Time v1 v2 v3 v4 …v16 \n"); for(t=0.0;t<=500.0;t++) {for(m=1;m<=nn;m++) {V[m]=0; if(m==1) gosub1(); for(k=p[m-1]+1;k<=p[m];k++) V[m]=V[m]+U[T[k]+1][k]*A[k]; if(m>=n9) {m1=m-n9+1; if(K[m1]==1) gosub2(); if(V[m]>U9[m1]) {K[m1]=1; gosub2();} } }

for(t=0.0;t<=500.0;t++) {for(m=1;m<=nn;m++) {V[m]=0; if(m==1) gosub1(); for(k=p[m-1]+1;k<=p[m];k++) V[m]=V[m]+U[T[k]+1][k]*A[k]; if(m>=n9) {m1=m-n9+1; if(K[m1]==1) gosub2(); if(V[m]>U9[m1]) {K[m1]=1; gosub2(); } }} for(n=1;n<=mm;n++) { if(I[n]>=J[n]) {for(m=1;m<=mm;m++) {if((I[n]==J[m])&&(I[m]==J[n])) { U[1][n]=V[J[n]]-U[T[m]+1][m]; U[1][m]=V[I[n]]-U[T[n]+1][n]; }}}} fprintf(ft,"%.3f",t); for(i=1;i<=nn;i++) fprintf(ft,"%10.3f ",V[i]); fprintf(ft,"\n"); gosub3(); } fclose(fp); fclose(ft);

fp=fopen("d:/tl/grid2out.txt","r"); for(i=1;i<=504;i++) { fgets(x,sizeof(x),fp); if(i==1||i==2||i==3||i==4) continue; sscanf(x,"%f %f %f %f %f",&time[i-4],&temp[1],&temp[2], &temp[3],&temp[4]); v1[i-4]=temp[1]; v2[i-4]=temp[2]; v3[i-4]=temp[3]; v4[i-4]=temp[4]; } fclose(fp); coordinate(); getch(); setcolor(1); drawpicture(time,v1,500,10); mark(1); setcolor(2); drawpicture(time,v2,500,10); mark(2); setcolor(4); drawpicture(time,v3,500,10); mark(3); setcolor(4); drawpicture(time,v4,500,10); mark(4); fp=fopen("d:/tl/grid2out.txt","r"); for(i=1;i<=504;i++) { fgets(x,sizeof(x),fp); if(i==1||i==2||i==3||i==4) continue; sscanf(x,"%f%f%f%f%f%f%f%f%f",&time[i-4],&temp[1],&temp[2],&temp[3],&temp[4],&temp[5],&temp[6],&temp[7],&temp[8]); v1[i-4]=temp[5]; v2[i-4]=temp[6]; v3[i-4]=temp[7]; v4[i-4]=temp[8]; } fclose(fp); setcolor(5); drawpicture(time,v1,500,10); mark(5); setcolor(6); drawpicture(time,v2,500,10); mark(6); setcolor(1); drawpicture(time,v3,500,10); mark(7); setcolor(8); drawpicture(time,v4,500,10); mark(8); fp=fopen("d:/tl/grid2out.txt","r"); for(i=1;i<=504;i++) {fgets(x,sizeof(x),fp); if(i==1||i==2||i==3||i==4) continue; sscanf(x,"%f%f%f%f%f%f%f%f%f%f%f %f%f",&time[i-4],&temp[1],&temp[2],&temp[3],&temp[4],&temp[5],&temp[6],&temp[7],&temp[8],&temp[9],&temp[10],&temp[11],&temp[12]); v1[i-4]=temp[9]; v2[i-4]=temp[10]; v3[i-4]=temp[11]; v4[i-4]=temp[12]; } fclose(fp); setcolor(2); drawpicture(time,v1,500,10); mark(9); setcolor(12); drawpicture(time,v2,500,10); mark(10); setcolor(9); drawpicture(time,v3,500,10); mark(11); setcolor(12); drawpicture(time,v4,500,10); mark(12); fp=fopen("d:/tl/grid2out.txt","r"); for(i=1;i<=504;i++) {fgets(x,sizeof(x),fp); if(i==1||i==2||i==3||i==4) continue; sscanf(x,"%f%f%f%f%f%f%f%f%f%f%f%f%f%f %f%f%f",&time[i-4],&temp[1],&temp[2],&temp[3],&temp[4],&temp[5],&temp[6],&temp[7],&temp[8],&temp[9],&temp[10],&temp[11],&temp[12],&temp[13],&temp[14],&temp[15],&temp[16]); v1[i-4]=temp[13]; v2[i-4]=temp[14]; v3[i-4]=temp[15]; v4[i-4]=temp[16]; } fclose(fp); setcolor(8); drawpicture(time,v1,500,10); mark(13); setcolor(6); drawpicture(time,v2,500,10); mark(14); setcolor(9); drawpicture(time,v3,500,10); mark(15); setcolor(2); drawpicture(time,v4,500,10); mark(16); getch(); closegraph(); } gosub1() { if(t*dt>tf) V[1]=u0; else V[1]=t*dt*u0/tf; } gosub2() {float z,I,I1; z=Z9[m1]; I1=0.001; do {I=I1; I1=I-(pow(I,A9[m1])+z/C9[m1]*I-V[m] /C9[m1])/(A9[m1]*pow(I,A9[m1]-1) +z/C9[m1]); }while(fabs((I1-I)/I1)>0.0001); V[m]=C9[m1]*pow(I1,A9[m1]); } gosub3() {int c,d; for(c=q;c>=2;c--) for(d=1;d<=mm;d++) U[c][d]=U[c-1][d]; } drawpicture(float x[],float y[],int n,int k) { int i,j,m; float x0,y0; float t1,t2,t3,t,a,b,c,d; m=n; x[0]=x[1]; y[0]=y[1]; x[n+1]=x[n]; y[n+1]=y[n]; t=0.5/k; moveto(20+x[1]*1.2,460-y[1]/4); for(i=0;i<m-1;i++) {for(j=1;j<k;j++) {t1=j*t; t2=t1*t1; t3=t2*t1; a=4.0*t2-t1-4.0*t3; b=1.0-10.0*t2+12.0*t3; c=t1+8.0*t2-12.0*t3; d=4.0*t3-2.0*t2; x0=a*x[i]+b*x[i+1]+c*x[i+2]+d*x[i+3]; y0=a*y[i]+b*y[i+1]+c*y[i+2]+d*y[i+3]; lineto(20+x0*1.2,460-y0/4); } lineto(20+x[i+2]*1.2,460-y[i+2]/4); } mark(int point) { if(point<=8) {moveto(350,point*10+320); lineto(350+50,point*10+320); } else {moveto(420,(point-8)*10+320); lineto(420+50,(point-8)*10+320);} switch(point) { case 1:outtext("v1");break; case 2:outtext("v2");break; case 3:outtext("v3");break; case 4:outtext("v4");break; case 5:outtext("v5");break; case 6:outtext("v6");break; case 7:outtext("v7");break; case 8:outtext("v8");break; case 9:outtext("v9");break; case 10:outtext("v10");break; case 11:outtext("v11");break; case 12:outtext("v12");break; case 13:outtext("v13");break; case 14:outtext("v14");break; case 15:outtext("v15");break; case 16:outtext("v16");break; }} coordinate() { int i; setcolor(8); outtextxy(25,20,"v"); moveto(20,20); lineto(17,24); moveto(23,24); lineto(20,20); lineto(20,460); outtextxy(15,460,"0"); lineto(620,460); outtext("t"); line(620,460,616,457); line(620,460,616,463); for(i=1;i<=7;i++) {moveto(20,460-i*200/4); lineto(25,460-i*200/4); switch(i) { case 1:outtext("200");break; case 2:outtext("400");break; case 3:outtext("600");break; case 4:outtext("800");break; case 5:outtext("1000");break; case 6:outtext("1200");break; case 7:outtext("1400");break; } } for(i=100;i<=400;i+=100) {moveto(20+i*1.2,455); lineto(20+i*1.2,460); switch(i) { case100:outtextxy(i*1.2,465,"100");break; case 200:outtextxy(i*1.2,465,"200");break; case 300:outtextxy(i*1.2,465,"300");break; case 400:outtextxy(i*1.2,465,"400");break; }}}

搜索更多相关主题的帖子: float include 
2005-05-21 10:31
pdzshui
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-5-21
得分:0 
如果哪位高手,该过来了,请将正确的答案发到邮箱 lwz0010@163.com, 谢谢了
2005-05-21 10:33



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-18892-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.056777 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved