标签:
每一个学生的数据占一行。
5 01 89 02 78 03 56 04 92 05 76
01 89 02 78 03 56 04 92 05 76
c++对象数组这样的东西,怎么说呢,灵活运用吧。反正代码是一看就能明确的。
#include<iostream>
#include<string>
using namespace std;
class student
{
private:
string i;
int g;
public:
void in()
{
cin >> i >> g;
}
void out()
{
cout << i << " " << g << endl;
}
};
int main()
{
int n,i;
student stu[500];
cin>>n;
for(i=0;i<n;i++)
stu[i].in();
for(i=0;i<n;i++)
stu[i].out();
return 0;
}
版权声明:本文博客原创文章。博客,未经同意,不得转载。
标签:
原文地址:http://www.cnblogs.com/bhlsheji/p/4631019.html