更新时间2019-06-09 23:26:04
#include <stdio.h>
#include <stdlib.h>
#define Pi 3.1415927
int main()
{
double Input,ra;
printf("Please input your number to calcution what you want 1.Ball's Volume 2.Surface Area of The Ball ");
scanf("%lf", &Input);
if (Input == 1)
{
printf(" V=(4/3)πr^3 Please input 'r' ");
scanf("%lf",&ra);
int f = (4 * Pi * ra * ra * ra / 3);
printf(f);这步显示f出错,int类型实参与const char*类型实参不兼容
getchar();
return 0;
}
按你的程序作了必要的几处修改:
#include <stdio.h>
#include <stdlib.h>
#define Pi 3.1415927
int main()
{
double Input,ra,f;
printf("Please input your number to calcution what you want
1.Ball's Volume
2.Surface Area of The Ball
");
scanf("%lf", &Input);
if (Input == 1)
{
printf("
V=(4/3)Pi*r^3
Please input 'r'
");
scanf("%lf",&ra);
f = (4 * Pi * ra * ra * ra / 3);
printf("%lf",f);
getch();
}
return 0;
}
程序能够运行了:
但是你的 2.Surface Area of The Ball 程序还未加入。