#include<iostream>
using namespace std;
#include<string>
int main(){
struct student
{
string name;
int age;
int score;
} s3 ;
s3.name = "小明";
s3.age = 21;
s3.score = 21;
cout << s3.name << endl;
cout << s3.age << endl;
cout << s3.score << endl;
struct student s1;
s1.name = "张三";
s1.age = 12;
s1.score = 98;
cout << s1.name << endl;
cout << s1.age << endl;
cout << s1.score << endl;
struct student s2 = {
"李四",14,100
};
cout << s2.name << endl;
cout << s2.age << endl;
cout << s2.score << endl;
}
#include <iostream>
using namespace std;
#include<string>
struct Student{
string name;
int age;
int score;
};
int main(){
struct Student stuArry[3] = {
{"张三",18,100
},
{"李四",10,89
},
{"王五",44,12
}
};
stuArry[2].name = "小明";
stuArry[2].age = 56;
stuArry[2].score = 22;
for(int i=0;i<3;i++){
cout << "姓名"<<stuArry[i].name<< endl;
cout << "年龄"<<stuArry[i].age<< endl;
cout << "分数"<<stuArry[i].score<< endl;
}
}
#include <iostream>
using namespace std;
#include<string>
struct Student{
string name;
int age;
int score;
};
int main(){
struct Student s = {"张三",18,56
};
struct Student * p = &s;
cout << "姓名" << p->name << p->age << p->score << endl;
}
#include <iostream>
using namespace std;
#include<string>
struct student{
string name;
int age;
int score;
};
struct teacher{
int id;
string name;
int age;
struct student stu;
};
int main(){
teacher t;
t.id=77777;
t.name="li";
t.age=28;
t.stu.name="小明";
t.stu.age=18;
t.stu.score=66;
cout <<"老师姓名"<<t.name <<"老师编号"<<t.id<<endl;
cout<< "老师年龄"<<t.age<< endl;\
cout<<"老师辅导学生"<<t.stu.name<<t.stu.age<<t.stu.score<< endl;
}