谁能帮我将以下简单的C程序改成下拉菜单式的!
#include <stdio.h> #include <stdlib.h>
#include <math.h>
#include <windows.h>
#define pi 3.14159
double volum3(double s,double h)
{return 1.0/3*s*h;
}
double area2(double a,double b)
{ double s1,s2;
s1=2.0*pi*a*b;
s2=pi*a*a;
return s1+s2;
}
double area1 (double a,double b)
{double s1,s2;
s1=pi*a*sqrt(a*a+b*b);
s2=pi*a*a;
return s1+s2;
}
double volume1 (double a,double b)
{double v;
v=pi*a*a*b*1.0/3;
return v;
}
main()
{int t,p,i=0;
double s1,s2,s3,v1,v2,v3,r1,h1,r2,h2,h3;
loop2: printf(" please press the code(two thousands and nine):");
scanf("%d",&p);
if(p==2009)
{ getchar();
system("CLS");
for(i=0;i <1;i++)
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf(" welcome to you\n\n");
Sleep(3000);
system("cls");
loop:
printf(" ==================================\n");
printf(" |1.the Calculation of cones |\n");
printf(" ==================================\n");
printf(" |2.the Calculation of cylinders|\n");
printf(" ==================================\n");
printf(" |3.the Calculation of pyramids|\n");
printf(" ==================================\n");
printf(" |0. exit the program |\n");
printf(" ==================================\n");
scanf("%d",&t);system("cls");
switch(t)
{case 1:printf("please output of the bottom radius of cone\n");
scanf("%lf",&r1);
if(r1 <=0) {printf("error");goto loop;}
printf("please output of the high of cone\n");
scanf("%lf",&h1);
if(h1 <=0) {printf("error");goto loop;}
v1=volume1 (r1,h1);
s1=area1(r1,h1);
printf("the volum is %f\n the area is%f\n",v1,s1); break;
case 2:printf("please output of the bottom radius of the cylinder\n");
scanf("%lf",&r2);
if(r2 <=0) {printf("error");goto loop;}
printf("please output of the high of cylinder\n");
scanf("%lf",&h2);
if(h2 <=0) {printf("error");goto loop;}
v2=3*volume1(r2,h2);
s2=area2(r2,h2);
printf("the volum is %lf\n the area is%lf\n",v2,s2);break;
case 3:printf("please output the footprint of pyramid\n");
scanf("%lf",&s3);
printf("please output of the high of pyramid\n");
scanf("%lf",&h3);
if(s3 <=0) {printf("error");goto loop;}
v3=volum3(s3,h3);
printf("the volum is %lf\n ",v3);break;
case 0:
for(i=0;i <1;i++)
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf(" ************************************************* \n");
printf(" | Thank you for using |\n");
printf(" ************************************************* \n");
printf("\n");
printf("\n");
printf("\n");
printf(" please wait for a few seconds to exit the program");
Sleep(3000);
system("cls");
exit(0);break;
default:printf("please output the right number\n");goto loop;
}
getchar();getchar();system("CLS");
goto loop;
}
else printf("the code is error\n");goto loop2;
}