#include<iostream>
#include<string>
using namespace std;
typedef double weight,tall;
struct student{
int number;
int score;
string name;
weight w;
tall t;
};
int main(){
student s[4]={{1,100,"wendy"},
{2,98,"susan"},
{3,87,"joker"},
{4,99,"du"}
};
cout<<"body check list: "<<endl;
for(int i=0;i<4;i++)
{cout<<s[i].name<<"\t["<<i+1<<"]号 tall=";
cin>>s[i].t;
cout<<"\t weight=";
cin>>s[i].w;
}
return 0;
}
贴上正确的输出:
这里tall和weight都是自己可以输入的
先贴上正确的;讲讲我刚刚错的地方:
struct student{
int number;
int name;
string score;
weight w;
tall t;
};
可以看到和上面的区别,name和score位置颠倒,结果输出一直是:
另外,struct第三行,得是string不能是int,不然直接报错