(一个C语言初学者)帮帮忙,这段程序哪里有问题,怎么不能运行呢?#include <stdio.h>

2025-01-28 01:19:32
推荐回答(3个)
回答1:

double zhouchang();
double mianji();
改为
double zhouchang(double r);
double mianji(double r);

n=zhouchang(double r);
s=mianji(double r);
改为
n=zhouchang(r);
s=mianji(r);

函数声明时要说明参数类型,调用时不用再写类型的。

回答2:

#include
#include
#define PI 3.14
double zhouchang(double);
double mianji(double);
void main()
{
double r,n,s;
printf("请输入圆的半径:");
scanf("%lf",&r);
n=zhouchang(r);
s=mianji(r);
printf("周长为:%.2f,面积为:%.2f",n,s);
}
double zhouchang(double r)
{
double t;
t=2*PI*r;
return t;
}
double mianji(double r)
{
double m;
m=PI*pow(r,2);
return m;
}

回答3:

把这一条‘double zhouchang(double r);’复盖‘double zhouchang(); ’
同样的‘double mianji(double r); ’复盖;‘double mianji(); ’

继续努力呀!