Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <cmath>
- #include <string>
- #include <math.h>
- #include <sstream>
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- #include <vector>
- #include <string>
- #include <cstdlib>
- #define _USE_MATH_DEFINES
- using namespace std;
- struct student {
- float body;
- string name;
- int spravna;
- int spatna;
- int nezodpovezena;
- };
- int main()
- {
- string radek;
- string soubor;
- string spravneOdpovedi = "AACCCCABBBBAAAAAAAAAAAAAAA";
- ifstream * dokumentace = new ifstream("soubor.txt");
- //ifstream dokumentace("soubor.txt");
- if (!dokumentace->is_open())
- {
- cout << "Chyba nacteni souboru." << endl;
- return 0;
- }
- int studentCount = 0;
- int pocetRadku = 0;
- int iEnd = 0;
- student * poleStudentu = new student[50];
- for (int i = 0; i < 50; i++)
- {
- poleStudentu[i].body = 0;
- poleStudentu[i].nezodpovezena = 0;
- poleStudentu[i].spatna = 0;
- poleStudentu[i].spravna = 0;
- }
- while (getline(*dokumentace, radek))
- {
- studentCount++;
- //student * newPoleStudentu = new student[studentCount];
- for (int i = 0; i < studentCount; i++)
- {
- //newPoleStudentu[i].body = 0;
- //newPoleStudentu[i].name = "";
- }
- // kopirovina stareho pole do vetsiho noveho
- for (int i = 0; i < studentCount - 1; i++)
- {
- //newPoleStudentu[i] = poleStudentu[i];
- }
- //
- for (int i = 0; i < radek.length(); i++)
- {
- if (radek[i] == ':')
- {
- // uchovani pozice v radku
- iEnd = i + 2;
- break;
- }
- poleStudentu[studentCount - 1].name += radek[i];
- }
- for (int j = 0; j < radek.length() - iEnd; j++)
- {
- if (radek[j + iEnd] == '0')
- {
- poleStudentu[studentCount - 1].nezodpovezena++;
- continue;
- }
- if (radek[j + iEnd] == spravneOdpovedi[j])
- {
- poleStudentu[studentCount - 1].body += 1;
- poleStudentu[studentCount - 1].spravna++;
- }
- else
- {
- poleStudentu[studentCount - 1].body -= 0.25;
- poleStudentu[studentCount - 1].spatna++;
- }
- }
- }
- for (float j = 25; j >= -6.25; j-= 0.25)
- {
- for (int i = 0; i < studentCount; i++)
- {
- if ( poleStudentu[i].body == j)
- {
- cout << poleStudentu[i].name << " pocet bodu: " << poleStudentu[i].body << " pocet spravne: " << poleStudentu[i].spravna
- << " pocet spatne : " << poleStudentu[i].spatna << " pocet nezodpovezenych: " << poleStudentu[i].nezodpovezena << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement