| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 447 人关注过本帖
标题:哪位大哥大姐帮我改下这个程序啊,报错说说明语法错误。谢谢
只看楼主 加入收藏
wxuwen0116
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2009-9-22
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
哪位大哥大姐帮我改下这个程序啊,报错说说明语法错误。谢谢
#include<stdlib.h>
#include<stdio.h>
#include<alloc.h>
#include<graphics.h>
#include<process.h>
#include<dos.h>
#include<conio.h>
#include<math.h>
main()
{int driver=VGA;
 int mode=VGAHI ;
 int i,dt;
 double x1[80],y1[80],ex,ey,xs,ys,x[11],y[11],Ex,Ey;
 initgraph(&driver,&mode,"");
 setfillstyle(1,7);
 bar(20,20,620,460);
 setbkcolor(8);
 setcolor(4);
 circle(250,240,10);
 circle(390,240,10);
 setcolor(1);
 settextstyle(GOTHIC_FONT,HORIZ_DIR,2);
 outtextxy(246,230,"_+");
 outtextxy(386,230,"-");
  for(i=0;;20>=xs&&xs<=320&&ys<=240&&ys>=20)
  {Ex=-(x[i]-390)/pow((x[i]-390)*(x[i]-390)+(240-y[i])*(240-y[i]),1.5)+(x[i]-250)/pow((x[i]-250)*(x[i]-250)+(240-y[i])*(240-y[i]),1.5);
   Ey=-(240-y[i])/poe((x[i]-390)*(x[i]-390)+(240-y[i])*(240-y[i]),1.5)+(240+y[i])/poe((x[i]-250)*(x[i]-250)+(240-y[i])*(240-y[i]),1.5);
   x[i]+=dt*Ex;
   y[i]-=dt*Ey;
   setcolor(5);
   line((int)xs,(int)ys,(int)x[i],(int)y[i]);
   line((int)xs,480-(int)ys,(int)x[i],480-(int)y[i]);
   line(640-(int)xs,(int)ys,640-(int)x[i],(int)y[i]);
   line(640-(int)xs,480-(int)ys,640-(int)x[i],480-(int)y[i]);
   xs=x[i];
   ys=y[i];

  }
      }

   setcolor(9);
   outtextxy(25,470,"please inter any char to continue:");
   getchar();
      i=0;
   do
  {
   x1[0]=320;
   y1[0]=240;
   y1[i+1]=240;
  Ex=-(x1[i]-390)/pow((x1[i]-390)*(x1[i]-390)+(240-y1[i])*(240-y1[i]),1.5)+(x1[i]-250)/pow((x1[i]-250)*(x1[i]-250)+(240-y1[i])*(240-y1[i]),1.5);
  Ey=-(240-y1[i])/pow((x1[i]-390)*(x1[i]-390)+(240-y1[i])*(240-y1[i]),1.5)+(240-y1[i])/pow((x1[i]-250)*(x1[1]-250)+(240-y1[i])*(240-y1[i]),1.5);
  x1[i]-=dt*Ey;
  y1[i]-=dt*Ex;
  setcolor(2);
  line((int)xs,(int)x1[i],(int)ys,(int)y1[i]);
  line((int)xs,480-(int)x1[i],(int)ys,480-(int)y1[i]);
  line(640-(int)xs,(int)x1[i],640-(int)ys,(int)y1[i]);
  line(640-(int)xs,480-(int)x1[i],640-(int)ys,480=(int)y1[i]);
  xs=x1[i];
  ys=y1[i];
  }
  i++;
 {while(x1[i]>260&&i<=40);getchar();}


搜索更多相关主题的帖子: 语法 大姐 
2009-09-22 07:51
北辰羽光
Rank: 2
来 自:福建
等 级:论坛游民
帖 子:50
专家分:26
注 册:2009-4-17
收藏
得分:10 
这么长的代码应该适当给注释的
2009-09-22 09:26
beyond_one
Rank: 4
等 级:业余侠客
帖 子:61
专家分:206
注 册:2009-6-26
收藏
得分:10 
几个明显错误:

#include<stdlib.h>
#include<stdio.h>
#include<alloc.h>
#include<graphics.h>
#include<process.h>
#include<dos.h>
#include<conio.h>
#include<math.h>
main()
{int driver=VGA;
int mode=VGAHI ;
int i,dt;
double x1[80],y1[80],ex,ey,xs,ys,x[11],y[11],Ex,Ey;
initgraph(&driver,&mode,"");
setfillstyle(1,7);
bar(20,20,620,460);
setbkcolor(8);
setcolor(4);
circle(250,240,10);
circle(390,240,10);
setcolor(1);
settextstyle(GOTHIC_FONT,HORIZ_DIR,2);
outtextxy(246,230,"_+");
outtextxy(386,230,"-");
  for(i=0;;20>=xs&&xs<=320&&ys<=240&&ys>=20) /*循环条件不对*/
  {Ex=-(x[i]-390)/pow((x[i]-390)*(x[i]-390)+(240-y[i])*(240-y[i]),1.5)+(x[i]-250)/pow((x[i]-250)*(x[i]-250)+(240-y[i])*(240-y[i]),1.5);
   Ey=-(240-y[i])/poe((x[i]-390)*(x[i]-390)+(240-y[i])*(240-y[i]),1.5)+(240+y[i])/poe((x[i]-250)*(x[i]-250)+(240-y[i])*(240-y[i]),1.5);/*pow()写成了poe*/
   x[i]+=dt*Ex;
   y[i]-=dt*Ey;
   setcolor(5);
   line((int)xs,(int)ys,(int)x[i],(int)y[i]);
   line((int)xs,480-(int)ys,(int)x[i],480-(int)y[i]);
   line(640-(int)xs,(int)ys,640-(int)x[i],(int)y[i]);
   line(640-(int)xs,480-(int)ys,640-(int)x[i],480-(int)y[i]);
   xs=x[i];
   ys=y[i];
 
  }
      }                 //多了一个大括号
 
   setcolor(9);
   outtextxy(25,470,"please inter any char to continue:");
   getchar();
      i=0;
   do
  {
   x1[0]=320;
   y1[0]=240;
   y1[i+1]=240;
  Ex=-(x1[i]-390)/pow((x1[i]-390)*(x1[i]-390)+(240-y1[i])*(240-y1[i]),1.5)+(x1[i]-250)/pow((x1[i]-250)*(x1[i]-250)+(240-y1[i])*(240-y1[i]),1.5);
  Ey=-(240-y1[i])/pow((x1[i]-390)*(x1[i]-390)+(240-y1[i])*(240-y1[i]),1.5)+(240-y1[i])/pow((x1[i]-250)*(x1[1]-250)+(240-y1[i])*(240-y1[i]),1.5);
  x1[i]-=dt*Ey;
  y1[i]-=dt*Ex;
  setcolor(2);
  line((int)xs,(int)x1[i],(int)ys,(int)y1[i]);
  line((int)xs,480-(int)x1[i],(int)ys,480-(int)y1[i]);
  line(640-(int)xs,(int)x1[i],640-(int)ys,(int)y1[i]);
  line(640-(int)xs,480-(int)x1[i],640-(int)ys,480=(int)y1[i]);           /*480=(int)y1[i]应该是480-(int)y1[i]吧*/
  xs=x1[i];
  ys=y1[i];                                    /*ys=y1[i];*/               
  }                                            /*i++;*/            
  i++;                                         /*  }   */
{while(x1[i]>260&&i<=40);getchar();}          /*while(x1[i]>260&&i<=40);getchar();}   */



改后的:
#include<stdlib.h>
#include<stdio.h>
#include<alloc.h>
#include<graphics.h>
#include<process.h>
#include<dos.h>
#include<conio.h>
#include<math.h>
main()
{
int driver=VGA;
int mode=VGAHI ;
int i,dt;
double x1[80],y1[80],ex,ey,xs,ys,x[11],y[11],Ex,Ey;
initgraph(&driver,&mode,"");
setfillstyle(1,7);
bar(20,20,620,460);
setbkcolor(8);
setcolor(4);
circle(250,240,10);
circle(390,240,10);
setcolor(1);
settextstyle(GOTHIC_FONT,HORIZ_DIR,2);
outtextxy(246,230,"_+");
outtextxy(386,230,"-");
  for(i=0;20>=xs&&xs<=320&&ys<=240&&ys>=20;i++)
  {
Ex=-(x[i]-390)/pow((x[i]-390)*(x[i]-390)+(240-y[i])*(240-y[i]),1.5)+(x[i]-250)/pow((x[i]-250)*(x[i]-250)+(240-y[i])*(240-y[i]),1.5);
   Ey=-(240-y[i])/pow((x[i]-390)*(x[i]-390)+(240-y[i])*(240-y[i]),1.5)+(240+y[i])/pow((x[i]-250)*(x[i]-250)+(240-y[i])*(240-y[i]),1.5);
   x[i]+=dt*Ex;
   y[i]-=dt*Ey;
   setcolor(5);
   line((int)xs,(int)ys,(int)x[i],(int)y[i]);
   line((int)xs,480-(int)ys,(int)x[i],480-(int)y[i]);
   line(640-(int)xs,(int)ys,640-(int)x[i],(int)y[i]);
   line(640-(int)xs,480-(int)ys,640-(int)x[i],480-(int)y[i]);
   xs=x[i];
   ys=y[i];
 
  }
 
   setcolor(9);
   outtextxy(25,470,"please inter any char to continue:");
   getchar();
      i=0;
   do
  {
   x1[0]=320;
   y1[0]=240;
   y1[i+1]=240;
  Ex=-(x1[i]-390)/pow((x1[i]-390)*(x1[i]-390)+(240-y1[i])*(240-y1[i]),1.5)+(x1[i]-250)/pow((x1[i]-250)*(x1[i]-250)+(240-y1[i])*(240-y1[i]),1.5);
  Ey=-(240-y1[i])/pow((x1[i]-390)*(x1[i]-390)+(240-y1[i])*(240-y1[i]),1.5)+(240-y1[i])/pow((x1[i]-250)*(x1[1]-250)+(240-y1[i])*(240-y1[i]),1.5);
  x1[i]-=dt*Ey;
  y1[i]-=dt*Ex;
  setcolor(2);
  line((int)xs,(int)x1[i],(int)ys,(int)y1[i]);
  line((int)xs,480-(int)x1[i],(int)ys,480-(int)y1[i]);
  line(640-(int)xs,(int)x1[i],640-(int)ys,(int)y1[i]);
  line(640-(int)xs,480-(int)x1[i],640-(int)ys,480-(int)y1[i]);
  xs=x1[i];
  ys=y1[i];
  i++;
}while(x1[i]>260&&i<=40);
getchar();
}


[ 本帖最后由 beyond_one 于 2009-9-22 21:16 编辑 ]
2009-09-22 17:36
beyond_one
Rank: 4
等 级:业余侠客
帖 子:61
专家分:206
注 册:2009-6-26
收藏
得分:0 
在我的电脑上编译通过了,但只实现了部分功能

[ 本帖最后由 beyond_one 于 2009-9-22 21:18 编辑 ]
2009-09-22 17:40
beyond_one
Rank: 4
等 级:业余侠客
帖 子:61
专家分:206
注 册:2009-6-26
收藏
得分:0 
写程序最好多加注释

[ 本帖最后由 beyond_one 于 2009-9-22 21:19 编辑 ]
2009-09-22 17:43
快速回复:哪位大哥大姐帮我改下这个程序啊,报错说说明语法错误。谢谢
数据加载中...
 
   



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

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