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;
const int STUDENTS = 10;
const int SCORES = 5;
void namesAndGrades(string name[], int id[], int grade[][SCORES], int oGrade[]);
int main(){
int ids[STUDENTS];
char o;
string names[STUDENTS];
int grades[STUDENTS][SCORES];
int overGrade[STUDENTS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
namesAndGrades (names[], ids[], grades[][SCORES], overGrade[]);
}
void namesAndGrades(string name[], int id[], int grade[][SCORES], int oGrade[]){
char o;
ifstream inFile;
inFile.open("data121.txt");
if ("data121.txt"){
for(int i=0; i<STUDENTS; i++){
inFile >> id[i]>>o;
getline(inFile, name[i], ',');
cout<<endl << id[i]<<" ";
cout << name[i]<< " ";
for(int x=0; x<SCORES;x++){
inFile>>grade[i][x]>>o;
oGrade[i]+=grade[i][x];
cout<< grade[i][x]<< " ";
}
cout<< oGrade[i]<<endl;
}
}
}
|