ch10_10.cpp
来自「本文档是(作者:钱能)《C++程序设计教程》系列的部分辅助代码。 选题编辑:张」· C++ 代码 · 共 36 行
CPP
36 行
//***********************
//** ch10_10.cpp **
//***********************
#include <iostream.h>
struct Person
{
char name[20];
unsigned long id;
float salary;
};
void GetPerson(Person& p) //结构参数引用传递的函数
{
cout <<"Please enter a name for one person:\n";
cin>>p.name;
cout <<"Please enter one's id number and his salary:\n";
cin >>p.id >>p.salary;
}
void Print(Person& p)
{
cout <<p.name <<" "
<<p.id <<" "
<<p.salary <<endl;
}
void main()
{
Person employee[3];
for(int i=0; i<3; i++){
GetPerson(employee[i]); //调用后,employee[i]被赋值
Print(employee[i]);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?