注册 登录
编程论坛 C语言论坛

求助这道题(矩形定义和计算)

cj攵 发布于 2021-03-28 17:10, 1113 次点击
#include<stdio.h>
struct Rectangle{double length,width;};
struct Rectangle initRectange(double len,double wid)
{
   struct Rectangle r;
   r.length=len;
   r.width=wid;
   return r;
}
  double girth(struct Rectangle r)
{
  return 2*(r.length+r.width);
}
   double area(struct Rectangle r)
{
   return r.length*r.width;
}
int main ( void ){
   double len,wid;
   double p,s;
   struct Rectangle r;
   printf("请输入一个矩阵的长和宽:");
   scanf("%lf %lf",&len,&wid);
   r=initRectangle(len,wid);
   p=girth(r);
   s=area(r);
   printf("矩阵的长和宽:%lf %lf\n",r.length,r.width);
   printf("矩阵的周长%lf\n",p);
   printf("矩阵的面积:%lf\n",s);
}
程序显示错误:[Error] 'initRectangle' was not declared in this scope
1 回复
#2
rjsp2021-03-28 18:01
如果你不信的话,那可以将其拷贝出来比较一下嘛
initRectange
initRectangle
1