C/TC程序调试问题

来源:百度知道 编辑:UC知道 时间:2024/07/02 12:11:08
#include <graphics.h>//图像
#include <math.h>//函数
#include <stdio.h>
#define e 2.7
double a,b,i=1.0/1000,sum=0,x,x2,y,y2,n,ex=1;
void main()
{
printf("please input a and b:\n");
scanf("%d %d",&a,&b);
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");/*初始化图形模式*/
setbkcolor(WHITE); //背景设为白色
setcolor(LIGHTRED); //画图颜色设为亮红色
{
outtextxy(320,245,"0,0"); //设坐标原点
for (x=a;x<=b;)
{
for(n=1;n<=x;n++)
{
ex=ex*e;
}
y2=4/ex;
sum+=y2*i;
x2=x+i;
line(x+320,y+245,x2+320,y2+245);//连接(x,y)、(x2,y2)
x=x2;
y=y2;
if x%10==0;
outtextxy(x+320,y+245,"x=%d,y=%d"); //每隔10记录一次x,y的值
}
getchar();/*暂停*/
closegraph();/*关闭图形模式*/
printf("jifen:%d",sum);
}
}
}

#include <graphics.h>
#include <math.h>
#include <stdio.h>
#define e 2.7
double a,b,i=1.0/1000,sum=0,x,x2,y,y2,n,ex=1;
void main()
{
printf("please input a and b:\n");
scanf("%d %d",&a,&b);
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");
setbkcolor(WHITE);
setcolor(LIGHTRED);
{
outtextxy(320,245,"0,0");
for (x=a;x<=b;)
{
for(n=1;n<=x;n++)
{
ex=ex*e;
}
y2=4/ex;
sum+=y2*i;
x2=x+i;
line(x+320,y+245,x2+320,y2+245);
x=x2;
y=y2;
if (x/10==0)
outtextxy(x+320,y+245,"x=%d,y=%d");
}
getchar();
closegraph();
printf("jifen:%d",sum);
}
}
}
改为if (x/10==0)
经调试后运行的结果为
jifen//0