ch10_9.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:

C#编程

开发平台:

Visual C++

  1. //**********************
  2. //**    ch10_9.cpp    **
  3. //**********************
  4. #include <iostream.h>
  5. struct Person
  6. {
  7.   char name[20];
  8.   unsigned long id;
  9.   float salary;
  10. };
  11. Person GetPerson()
  12. {
  13.   Person temp;
  14.   cout <<"Please enter a name for one person:n";
  15.   cin>>temp.name;
  16.   cout <<"Please enter one's id number and his salary:n";
  17.   cin >>temp.id >>temp.salary;
  18.   return temp;
  19. }
  20. void Print(Person& p)
  21. {
  22.   cout <<p.name <<"    "
  23.        <<p.id <<"    "
  24.        <<p.salary <<endl;
  25. }
  26. void main()
  27. {
  28.   Person employee[3];
  29.   for(int i=0; i<3; i++){
  30.     employee[i]=GetPerson();
  31.     Print(employee[i]);
  32.   }
  33. }