c语言:输入几何形状,求相应周长和面积
#include<stdio.h>#include<math.h>#include<windows.h>#include<string.h>#definepi3.1415...
# include <stdio.h>
# include <math.h>
# include <windows.h>
# include <string.h>
# define pi 3.1415926
int main(void)
{
char n[2];
double a,b,r,s,c;
printf("enter n:");
scanf("%s",n);
if(strcmp(n,"rectangle")==0)
printf("enter a:");
scanf("%lf",&a);
printf("enter b:");
scanf("%lf",&b);
s=a*b;
c=2*(a+b);
if(strcmp(n,"circular")==0)
printf("enter r:");
scanf("%lf",&r);
s=pi*pow(r,2);
c=2*pi*r;
printf("s=%.2f,c=%.2f",s,c);
system("pause");
return 0;
}
求大神们看看哪里出问题了,感激不尽,c新手 展开
# include <math.h>
# include <windows.h>
# include <string.h>
# define pi 3.1415926
int main(void)
{
char n[2];
double a,b,r,s,c;
printf("enter n:");
scanf("%s",n);
if(strcmp(n,"rectangle")==0)
printf("enter a:");
scanf("%lf",&a);
printf("enter b:");
scanf("%lf",&b);
s=a*b;
c=2*(a+b);
if(strcmp(n,"circular")==0)
printf("enter r:");
scanf("%lf",&r);
s=pi*pow(r,2);
c=2*pi*r;
printf("s=%.2f,c=%.2f",s,c);
system("pause");
return 0;
}
求大神们看看哪里出问题了,感激不尽,c新手 展开
若以下回答无法解决问题,邀请你更新回答
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询