[求助]大家帮我看看这两个if为什么不能工作
#include<graphics.h>#include<math.h>
#define PI 3.1415926
#define mid_x 320
#define mid_y 240
int main()
{
int i,l,j=45,x1,x2,y1,y2,x3,y3;
int driver=DETECT,mode;
initgraph(&driver,&mode," ");
setbkcolor(BLACK);
while (getch()!='q')
{
cleardevice();
setcolor(WHITE);
setfillstyle(1,4);
pieslice(mid_x,mid_y,0,60,180);
setfillstyle(1,0);
pieslice(mid_x,mid_y,0,60,145);
setfillstyle(1,0);
pieslice(320,240,0,180,145);
arc(mid_x,mid_y,0,180,180);
circle(mid_x,mid_y,2);
line(500,240,140,240);
for(i=15;i<45;i++)
{
if(i%5==0)
l=20;
else
l=10;
x1=180*sin(i*6*PI/180)+320;
y1=180*cos(i*6*PI/180)+240;
x2=(180-l)*sin(i*6*PI/180)+320;
y2=(180-l)*cos(i*6*PI/180)+240;
line(x1,y1,x2,y2);
}
settextjustify(1,1);
outtextxy(320,80,"45");
outtextxy(160,230,"0");
outtextxy(480,230,"90");
outtextxy(400,100,"60");
outtextxy(240,100,"30");
outtextxy(450,160,"75");
outtextxy(180,160,"15");
x3=180*sin(j*6*PI/180)+320;
y3=180*cos(j*6*PI/180)+240;
switch(getch())
{
case '-':j=j+1;break;
case '=':j=j-1;break;
}
setcolor(RED);
if (15<=j<=45)
line(x3,y3,mid_x,mid_y);
if (15<=j<=25)
{window(250,245,390,265);
textattr(RED+(BLACK<<4));
cprintf("WARMING!!");
}
getch();
}
return 0;
}
就是后面的两个if,为什么不能正常工作呢?
----------------解决方案--------------------------------------------------------
“15<=j<=45”这么写条件对么?好像要用“&&”吧
“int driver=DETECT,mode;”这个是什么意思啊“=”后面的不应该用“;”么怎么用“,”了?
----------------解决方案--------------------------------------------------------
晕。。。。。
15<=j<=45可不等于(j>=15)&&(j<=45)啊
后面是指定自动检测图形系统的显示模式
----------------解决方案--------------------------------------------------------
回复 3# 的帖子
奥 那是我误解了 ----------------解决方案--------------------------------------------------------