ch10_9.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //**********************
- //** ch10_9.cpp **
- //**********************
- #include <iostream.h>
- struct Person
- {
- char name[20];
- unsigned long id;
- float salary;
- };
- Person GetPerson()
- {
- Person temp;
- cout <<"Please enter a name for one person:n";
- cin>>temp.name;
- cout <<"Please enter one's id number and his salary:n";
- cin >>temp.id >>temp.salary;
- return temp;
- }
- void Print(Person& p)
- {
- cout <<p.name <<" "
- <<p.id <<" "
- <<p.salary <<endl;
- }
- void main()
- {
- Person employee[3];
- for(int i=0; i<3; i++){
- employee[i]=GetPerson();
- Print(employee[i]);
- }
- }