求助:结构体的使用
郁闷,一上来一大片错误,是在不会改,兄弟们帮帮忙吧#include<iostream.h>
struct family //定义结构体
{
int biaohao;
int shouru;
int member;
}family;
void IN(family); //声明,这是一个输入结构体成员的函数
void xianshi(family); //显示结构体成员的函数
void average(family); //求平均数的函数
void main()
{
family 1,2,3,4,5; //结构体声明
cout<<"输入标识号,年收入,家庭成员个数:"<<endl;
IN(family);
xianshi(family);
average(family);
}
void IN(family name1)
{
cout<<"输入第1个家庭的数据:"<<endl;
cin>>1.biaohao>>1.shouru>>1.member;
cout<<"输入第2个家庭的数据:"<<endl;
cin>>2.biaohao>>2.shouru>>2.member;
cout<<"输入第3个家庭的数据:"<<endl;
cin>>3.biaohao>>3.shouru>>3.member;
cout<<"输入第4个家庭的数据:"<<endl;
cin>>4.biaohao>>4.shouru>>4.member;
cout<<"输入第5个家庭的数据:"<<endl;
cin>>5.biaohao>>5.shouru>>5.member;
}
void xianshi(family name2)
{
cout<<"标识号"<<" "<<"年收入"<<" "<<"监听成员人数"<<endl;
cout<<1.biaohao<<" "<<1.shouru<<" "<<1.member<<endl;
cout<<2.biaohao<<" "<<2.shouru<<" "<<2.member<<endl;
cout<<3.biaohao<<" "<<3.shouru<<" "<<3.member<<endl;
cout<<4.biaohao<<" "<<4.shouru<<" "<<4.member<<endl;
cout<<5.biaohao<<" "<<5.shouru<<" "<<5.member<<endl;
}
void average(family name3)
{
int avg;
avg = (1.shouru + 2.shouru + 3.shouru + 4.shouru + 5.shouru);
cout<<"平均年收入为:"<<avg<<endl;
}
哪里有错误请指正,谢谢了