同一段代码,分别用codebloacks,vc2012,C4driod编译,出现三个不同结果。
代码如下:
//计算长方体体积和表面积
#include <stdio.h>
#include <ctype.h>
int main()
{
char answer = 'Y';
double length = 0.0;
double width = 0.0;
double height = 0.0;
double volume = 0.0;
double area = 0.0;
do
{
printf("Enter the value of length,width,height(separate them with space): \n");
scanf("%lf,%lf,%lf",&length,&width,&height);
volume = length*width*height;
area = (length*width+length*height+height*width)*2;
printf("The volume is %15.2lf\n",volume);
printf("The area is %15.2lf",area);
getchar();
printf("\nCalculate another cuboid?(Y/N)\n");
scanf("%c",&answer);
}while(toupper(answer) == 'Y');
return 0;
}
代码如下:
//计算长方体体积和表面积
#include <stdio.h>
#include <ctype.h>
int main()
{
char answer = 'Y';
double length = 0.0;
double width = 0.0;
double height = 0.0;
double volume = 0.0;
double area = 0.0;
do
{
printf("Enter the value of length,width,height(separate them with space): \n");
scanf("%lf,%lf,%lf",&length,&width,&height);
volume = length*width*height;
area = (length*width+length*height+height*width)*2;
printf("The volume is %15.2lf\n",volume);
printf("The area is %15.2lf",area);
getchar();
printf("\nCalculate another cuboid?(Y/N)\n");
scanf("%c",&answer);
}while(toupper(answer) == 'Y');
return 0;
}


