早教吧 育儿知识 作业答案 考试题库 百科 知识分享

请哪位高手帮编个计算表面积的程序具体要求就是,我输入长a宽b高c(单位:米),以及单价(元/平方米)后,可以计算出表面积,然后计算出价格,最好可以进行批量的算,就是可以输入若干个abc

题目详情
请哪位高手帮编个计算表面积的程序
具体要求就是,我输入长a宽b高c(单位:米),以及单价(元/平方米)后,可以计算出表面积,然后计算出价格,最好可以进行批量的算,就是可以输入若干个abc,最后得到一个总的结果
▼优质解答
答案和解析
#include "stdio.h"
main()
{
float a,b,c,p,sum,sa;
char t='y';
sa=0;
while(t=='y')
{printf("please input\n");
printf("a=");scanf("%f",&a);
printf("b=");scanf("%f",&b);
printf("c=");scanf("%f",&c); ;
printf("this superficial area=%f\n",2*(a*b+a*c+b*c));
printf("\n");
fflush(stdin);
printf("hit'Y'input again(or 'N' end):");
scanf("%c",&t);
sa=sa+2*(a*b+a*c+b*c);
}
printf("\n");
printf("the totle superficial area=%f\n",sa);
fflush(stdin);
printf("price=");scanf("%f",&p);
sum=sa*p;
printf("the totle sum=%f\n",sum);
system("pause");
}
看了 请哪位高手帮编个计算表面积的...的网友还看了以下: