发布网友 发布时间:2022-04-24 17:26
共4个回答
热心网友 时间:2023-10-26 02:18
#include<stdio.h>
int main()
{
int r;
printf("请输入r:");
scanf("%d",&r);
if(r>0)
printf("面积是:%f\n",2*3.1415*r*r);
else
printf("输入的r不合法!\n");
return 0;
}
热心网友 时间:2023-10-26 02:18
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int r;
double Area;
cin>>r;
Area=3.141592653579323*r*r;
cout<< fixed << setprecision(7)<<Area<<endl;
return 0;
}
望采纳!
热心网友 时间:2023-10-26 02:19
#include "stdio.h"
#include "process.h"
#define PI 3.1415926;
double calcAreaOfCircleByR(double r);//声明函数计算圆面积 r为半径
double calcAreaOfCircleByD(double d);//声明函数计算圆面积 d为直径
int main(int argc, char* argv[])
{
double r = 1.0;
double d = 2.0;
printf("半径r=%g的圆面积%g\n", r, calcAreaOfCircleByR(r));
printf("直径d=%g的圆面积%g\n", d, calcAreaOfCircleByD(d));
printf("\n");
system("pause");
return 0;
}
double calcAreaOfCircleByR(double r)//计算圆面积 r为半径
{
return (r)* (r)* PI;
}
double calcAreaOfCircleByD(double d)//计算圆面积 d为直径
{
return (d * d / 4) * PI;
}
热心网友 时间:2023-10-26 02:19
#include<stdio.h>
int main()
{
float x;
printf("输入圆半径:");
scanf("%f",&x);
printf("圆面积为:%f",3.1415*x*x);
return 0;
}
要采纳哦