Untitled
unknown
plain_text
24 days ago
1.2 kB
19
Indexable
#include <iostream> #include <fstream> #include <valarray> using namespace std; class student { public: string imie; string nazwisko; int punkty; student(const string &imie, const string &nazwisko, int punkty) : imie(imie), nazwisko(nazwisko), punkty(punkty) {} /*student() {}*/ }; int main() { int liczba_studentow; ifstream data("studenci.csv"); data >> liczba_studentow; cout << liczba_studentow << endl; student *studenci[liczba_studentow]; string imie, nazwisko; int punkty; string pomoc; getline(data, pomoc); int i = 0; while (!data.eof()) { getline(data, imie, ';'); getline(data, nazwisko, ';'); getline(data, pomoc); punkty = stoi(pomoc); /*cout<< imie << " " << nazwisko << " " << punkty <<endl;*/ studenci[i] = new student(imie, nazwisko, punkty); i++; } for (int j = 0; j < liczba_studentow; j++) { cout << studenci[j]->imie << " "; cout << studenci[j]->nazwisko << " "; cout << studenci[j]->punkty << endl; delete studenci[j]; } return 0; }
Editor is loading...
Leave a Comment