c语言程序代码分析
#include"graphics.h"#include"math.h"
void main()
{ float val[]={3.9,5.3,7.2,9.6,12.,10.0,23.2,31.4,39.8,50.2,62.9,56.0,92.0,105.7,122.8,125.7,150.7,179.3,203.2,211.0};
char *ch[]={"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"};
int i,j,x1,x2,y1,y2,n;
char str[10];
int graphdriver=DETECT,graphmode;
registerbgidriver(EGAVGA_driver);
initgraph(&graphdriver,&graphmode," ");
cleardevice();
setviewport(20,20,570,450,1);
setcolor(1);
n=20;
x1=80;
y1=390-1.5*val[0];
for(i=0;i<=n-1;i++)
{ x2=x1+20;
y2=390-1.5*val[i];
setcolor(12);
line(x1,y1,x2,y2);
setcolor(WHITE);
circle(x2,y2,1);
}
setcolor(WHITE);
line(80,390,500,390);
j=0;
for(i=100;i<=80+n*20;i=i+20)
{ line(i,390,i,400);
outtextxy(i-4,450,ch[j]);
j++;
}
outtextxy(200,420,"Every times");
line(80,390,80,5);
for(j=0;j<=300;j=j+50)
{ line(70,390-1.5*j,80,390-1.5*j);
sprintf(str,"%d",j);
outtextxy(45,390-1.5*j-3,str);
}
settextstyle(0,1,1);
outtextxy(30,40,"Values");
getch();
closegraph();
}
中的x1=80;
y1=390-1.5*val[0];
for(i=0;i<=n-1;i++)
{ x2=x1+20;
y2=390-1.5*val[i];
setcolor(12);
line(x1,y1,x2,y2);
setcolor(WHITE);
circle(x2,y2,1);
}
怎么理解啊?