7.5 һṹstuںѧѧš3ſεĳɼҪmainΪԱֵһprintнǵֵ
(1) ýṹ
#include <iostream>
#include <string>
using namespace std;
struct Student                            //ṹStudent
{ int num;
char name[20];                           
float score[3];
};

int main( )
{ void print(Student);                    //βΪṹStudent
Student stu;                            //ṹ
stu.num=12345;                          //5жԽṹԱֵ
stu.name=Li Fung;               
stu.score[0]=67.5;
stu.score[1]=89;
stu.score[2]=78.5;
print(stu);                             //printstuԱֵ    
return 0;
}

void print(Student stu)
{cout<<stu.num<< <<stu.name<< <<stu.score[0]<< 
<<stu.score[1]<< <<stu.score[2]<<endl;
}

(2) ָṹָʵ
#include <iostream>
#include <string>
using namespace std;
struct Student
{ int num;
string name;                         //stringͶַ
float score[3];
}stu={12345,Li Fung,67.5,89,78.5};   //ṹstudentstuֵ

int main( )
{ void print(Student *);          //βΪָStudentݵָ
Student *pt=&stu;               //ΪStudentָptָstu 
print(pt);                      //ʵΪָStudentݵָ
return 0;
}
void print(Student *p)            //庯βpǻΪStudentָ
{ cout<<p->num<< <<p->name<< <<p->score[0]<< 
<<p->score[1]<< <<p->score[2]<<endl;
}

(3) ýṹ
#include <iostream>
#include <string>
using namespace std;
struct Student
{ int num;
string name;
float score[3];
}stu={12345,Li Li,67.5,89,78.5};

int main( )
{ void print(Student &);             //βΪStudentͱ
print(stu);                        //ʵΪṹStudent
return 0;
}

void print(Student &stud)            //壬βΪṹStudent
{cout<<stud.num<< <<stud.name<< <<stud.score[0]<< 
<<stud.score[1]<< <<stud.score[2]<<endl;
}