1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void Data(int y, int &Groups, string *&Name, int &People, int *&Grades)
{
ifstream ifile("text.txt");
if(y==0)
{
ifile >> Groups;
cout << "Groups = " << Groups << "\n";
Name=new string[Groups];
}
ifile >> Name[y] >> People;
cout << "Name[" << y << "] = " << Name[y] << ", People = " << People << "\n";
Grades=new int[People];
for(int i=0;i<People;i++)
{
ifile >> Grades[i];
cout << "Grades[" << i << "] = " << Grades[i] << "\n";
}
}
int main()
{
int Groups, People, *Grades, g=0;
string *Name;
cout << "* * * call Data with g = " << g << "\n";
Data(g, Groups, Name, People, Grades);
for(g=1;g<Groups;g++)
{
cout << "* * * call Data with g = " << g << "\n";
Data(g, Groups, Name, People, Grades);
}
return 0;
}
|