关于C语言的编程题:编程从键盘输入圆柱体的半径r和高,计算并输出圆柱体的表面积和体积.

2024-12-14 19:43:24
推荐回答(3个)
回答1:

这个什么循环判断都不要一个输入一个输出就是啊,scanf("%d%d",&r,&h);printf("%d%d",3.14*2*r*h+2*3.14*r*r,3.14*r*r*h);

回答2:

#include "stdafx.h"
#include "stdio.h"
#include "conio.h"
#define PI 3.141592653589793

double surfaceArea(float r,float h){
return 2*PI*r*(r+h);
}
double volume(float r,float h){
return PI*r*r*h;
}

void main()
{
double r = 0,h = 0;
puts("input r and h:");
scanf("%f%f",&r,&h);

printf("surfaceArea = %f \n",surfaceArea(r, h));
printf("volume = %f \n",volume(r, h));

puts("\npress any key to exit.");
getch();
}

回答3:

#define PI 3.14
#include
main()
{ float r,h,S,V;
S=2*PI*r*(h+r);
V=2*PI*r*h*h;
please input r,h: scanf("%f,%f",&r,&h);
printf("S=%f,V=%f ",S,V);
getch();
}