#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,不然直接報錯