请大家帮看看这个程序,有些错误啊,改不出来.
#define m 16 #define n 3 #include<graphics.h> #include<stdio.h> #include<conio.h> #include<stdlib.h> #include<math.h> #include<time.h> void main() { int gmode,gdriver=DETECT; int R=6,D=450,i,j; float p,q; initgraph(&gdriver,&gmode," "); printf("(p,q):"); scanf("%d,%d",&p,&q); p=p*3.1415926/180; q=q*3.1415926/180; double a[m][n]={-1,-1,-1, 1,-1,-1, 1, 1,-1, -1, 1,-1, -1,-1, 1, 1,-1, 1, 1, 1, 1, -1, 1, 1, 0.5,-0.5, 0.5, 0.5,-0.5,-0.5, 0.5, 0.5,-0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,-0.5, -0.5, 0.5,-0.5,-0.5, 0.5, 0.5}; for(i=0;i<16;i++) { a[i][0]=(int)(-a[i][0]*sin(p)+a[i][1]*cos(q)); a[i][1]=(int)(-a[i][0]*cos(p)*cos(q)-a[i][1]*sin(p)*cos(q)+a[i][2]*sin(q)); a[i][2]=(int)(-a[i][0]*cos(p)*sin(q)-a[i][1]*sin(p)*sin(q)-a[i][2]*cos(q)+R); a[i][0]=(int)(a[i][0]*D/a[i][2]+100); a[i][1]=(int)(a[i][1]*D/a[i][2]+100); } for(i=0;i<4;i++) { j=i%4; line(a[i][0],a[i][1],a[j+1][0],a[j+1][1]); line(a[i][0],a[i][1],a[i+4][0],a[i+4][1]); } for(i=0;i<8;i++) { j=i%4+4; line(a[i][0],a[i][1],a[j+1][0],a[j+1][1]); } for(i=8;i<16;i++) { if(i==11) line(a[i][0],a[i][1],a[9][0],a[9][1]); if(i==15) line(a[i][0],a[i][1],a[13][0],a[13][1]); line(a[i][0],a[i][1],a[i+1][0],a[i+1][1]); } getch(); closegraph(); }