c program問題(dev c++)

2008-03-19 1:03 am
我想問以下ge output 應該點打

1.Please enter the length of the sides:7 11 (NUMBER自己打)
Area=77
2.Please enter the length of the sides and the height:7 10 3 (同上)
Area=25.5
3.Please enter the radius:5
Area=78.5375 (PI=3.1415)

THX

回答 (2)

2008-03-19 4:14 am
✔ 最佳答案
/* 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;
}
2008-03-19 1:35 am
Question 1, calculate the result of multiple 2 numbers.
Question 3, calculte the circle area with radiu.

Question 2, what do you calculate?


收錄日期: 2021-04-13 15:18:06
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080318000051KK01814

檢視 Wayback Machine 備份