|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
单叶双曲面(C语言)源代码
- #include <graphics.h>
- #include <math.h>
- #include <stdio.h>
- #define pi 3.1415926
- void main()
- {
- int graphdrive=DETECT,graphmode;
- int X[36],Y[36],x[36],y[36],i;
- float angle1,angle2,R1,R2,R,H;
- printf("Please input the radius of the ceil circle=R1(0~160):\n");
- scanf("%f",&R1);
- printf("Please input the radius of the bottom circle=R2(0~160):\n");
- scanf("%f",&R2);
- printf("Please input the radius of tht throat circle=R:\n");
- scanf("%f",&R);
- if(R>R1||R>R2)
- {
- printf("Yous input is ERROR!\n");
- return;
- }
- printf("Please the height of the bin-surface=H:\n");
- scanf("%f",&H);
- initgraph(&graphdrive,&graphmode,"");
- angle2=acos(R/R1)+acos(R/R2);
- cleardevice();
- setbkcolor(9);
- setcolor(15);
- setlinestyle(CENTER_LINE,2,NORM_WIDTH);
- line(160,25,160,500);
- line(25,400,300,400);
- setcolor(4);
- setlinestyle(SOLID_LINE,0,THICK_WIDTH);
- line(160-R1,280,160+R1,280);
- line(160-R2,280-H,160+R2,280-H);
- circle(160,400,R1);
- circle(160,400,R2);
- circle(160,400,R);
- setcolor(2);
- setlinestyle(SOLID_LINE,0,NORM_WIDTH);
- i=1;
- do{
- angle1=pi/18*i;
- x[i]=160+(R1*cos(angle1));
- X[i]=160+(R2*cos(angle1+angle2));
- y[i]=400+(R1*sin(angle1));
- Y[i]=400+(R2*sin(angle1+angle2));
- line(x[i],y[i],X[i],Y[i]);
- line(x[i],280,X[i],280-H);
- i++;
- }
- while(i<=36);
- getch();
- closegraph();
- }
复制代码 |
-
|