#include <iostream.h>
struct Rectanfle
{
float length,width;
};
Rectangle InitRectangle(float len, float wid);
float Circumference(Rectangle r);
float Area(Rectangle r);
void main()
{
float x,y;
float p,s;
Rectangle r;
cout<<"请输入一个矩形的长和宽!"<<endl;
cin>>x>>y;
r=InitRectangle(x,y);
p=Circumference(r);
s=Area(r);
cout<<endl;
cout<<"矩形的周长为:"<<P<<endl;
cout<<"矩形的面积为:"<<s<<endl;
}
Rectangle InitRectangle(float len,float wid)
{
Rectangle r;
r.length=len;
r.width=wid;
return r;
}
float Circumference(Rectangle r)
{
return 2*(r.length+r.width);
}
float Area(Rectangle r)
{
return r.length*r.width;
}
E:\学习\VC++文件夹\MSDev98\MyProjects\66\6.cpp(6) : error C2146: syntax error : missing ';' before identifier 'InitRectangle'
E:\学习\VC++文件夹\MSDev98\MyProjects\66\6.cpp(6) : error C2501: 'Rectangle' : missing storage-class or type specifiers
E:\学习\VC++文件夹\MSDev98\MyProjects\66\6.cpp(6) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
66.exe - 3 error(s), 0 warning(s)
请教大家了 谢谢!!