✔ 最佳答案
/* area
*/
#include < stdio.h>
int main(int argc, char * args[])
{
// rectangle
int n=0;
double l,w;
while(n!=2)
{
printf("1. Rectangle: Please enter the length of the sides:");
n=scanf("%lf%lf",&l,&w);
}
printf("Area=%lg\n",l*w);
// trapezium
n=0;
double l1,l2,h;
while(n!=3)
{
printf("2.Trapezium: Please enter the length of the sides and the height:");
n=scanf("%lf%lf%lf",&l1,&l2,&h);
}
printf("Area=%lg\n",(l1+l2)*h/2);
// circle
n=0;
double r,pi=3.14159265358979;
while(n!=1)
{
printf("3.Circle: Please enter the radius:");
n=scanf("%lf",&r);
}
printf("Area=%.4lf\n", pi*r*r);
printf("Thank you!\n");
return 0;
}