jwbf.net
当前位置:首页 >> C语言定义两个宏分别求圆的周长和面积 >>

C语言定义两个宏分别求圆的周长和面积

下载文件:1021113.zip

一、数学公式: 圆周长=2*π*半径 面积=π*半径² 二、算法分析: 周长和面积都依赖半径,所以要先输入半径值,然后套用公式,计算周长和面积。 最终输出结果即可。 三、参考代码: #include #define PI 3.14159int main(){ double r, s, c; s...

# include #define PI 3.1415926 using namespace std; void a() { double r,c,s; coutr; c=PI*r*2; s=PI*r*r; cout

#include "stdio.h" #define Pi 3.1415926 double zhouchang(double r) { double s; s=2*Pi*r; return s; } double mianji(double r) { double s; s=Pi*r*r; return s; } int main() { double r,m,n; printf("请输入圆的半径:"); scanf("%lf",&r...

#include#define Pi 3.14159double Square(double r){ return Pi * r * r;}double Perimeter(double r){ return 2 * Pi * r;}int main(){ double r; printf("请输入圆的半径:\n"); while(scanf("%lf",&r)!= EOF){ printf("圆的面积是%lf\n",Squ...

1.求圆面积和周长 c=πd=2πr 圆的周长=直径×圆周率s=πrr 圆的面积=半径×半径×圆周率 2.C++代码实现 #includeusing namespace std;const float PI=3.141593;class Circle {private :float radius;public:Circle(float r);Circle(Circle &C);float ...

void print(double r){ if (r 0 else printf("S = %lf, C = %lf\n", 3.14*r*r, 2*3.14*r);}

#include #define pi 3.1415926 void main() { float r,l,s; printf("请输入圆的半径:"); scanf("%f",&r); l=2*pi*r; s=pi*r*r; printf("圆的周长为:%f\n,圆的面积为:%f\n",l,s); }

#include #include #define Pi 3.1415926 int main() { float r,c,s,s1,v; scanf("%f",&r); c=2*Pi*r; s=Pi*pow(r,2); s1=4*s; v=4*Pi*pow(r,3)/3; printf("C=%f\nS=%f\nS1=%f\nV=%f\n",c,s,s1,v); return 0; }

不好意思,我不知道什么叫宏常量,我试着编了一下,您看看 #include int main() { double r =5.3; double a =3.14159; printf ("Area=%f\n",(long)a*r*r); printf ("circumference=%f\n",2*a*r); }

网站首页 | 网站地图
All rights reserved Powered by www.jwbf.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com