用c语言编写一个输入半径r1和半径r2求两个圆的周长和面积的代码
时间: 2023-05-26 22:01:57 浏览: 181
java代码-使用java计算圆类,半径r(double),计算周长,面积,π=3.14的源代码
5星 · 资源好评率100%
```c
#include <stdio.h>
#define PI 3.1415926535
int main() {
double r1, r2;
printf("请输入圆1的半径:");
scanf("%lf", &r1);
printf("请输入圆2的半径:");
scanf("%lf", &r2);
double c1 = 2 * PI * r1;
double s1 = PI * r1 * r1;
double c2 = 2 * PI * r2;
double s2 = PI * r2 * r2;
printf("圆1周长:%.2f,面积:%.2f\n", c1, s1);
printf("圆2周长:%.2f,面积:%.2f\n", c2, s2);
printf("两圆周长之和:%.2f,面积之和:%.2f\n", c1 + c2, s1 + s2);
return 0;
}
```
阅读全文