求C语言程序设计:

来源:百度知道 编辑:UC知道 时间:2024/09/20 18:28:49
设正方形和圆的面积相同,比较正方形的边长和圆直径的大小?如果正方形的边找等于直径,那哪个面积大?(在程序语句中,一些语句后面需要添加注释。)

我给你写吧,不过,你这个分也太少了吧?
#include<stdio.h>
#include<math.h>
#define pi 3.1415
void main(){
void sf();
float s,R,Ar,s1,s2; //R为圆的半径,Ar为正方形的边
Ar=sqrt(s);
R=sqrt(s/pi);
if((2*R)>(4*Ar)) printf("圆的直径大!\n");
else printf("正方形的边长大!\n");
sf();

}
void sf(){
float s,R,Ar,s1,s2; //s1为圆的面积,s2为正方形的面积
s1=pi*R*R;
s2=(R*R)/4;
if(s1>s2) printf("圆的面积大!\n");
else printf("正方形的面积大!\n");
}

#include<math.h>
main()
{
int s=1;
float d,a,k;
k=4*s/3.1415926;
d=sqrt(k);
a=sqrt(s);
if(d>a)
printf("d>a,(d stands for circle,a stands for square)");
if(d<a)
printf("d<a(d stands for circle,a stands for square)");
if(d==a)
printf("d=a(d stands for circle,a stands for square)");
}
#define M (A st