Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <cmath>
  4. #include <string>
  5. #include <math.h>
  6. #include <sstream>
  7. #include <iostream>
  8. #include <fstream>
  9. #include <algorithm>
  10. #include <vector>
  11. #include <string>
  12. #include <cstdlib>
  13.  
  14.  
  15. #define _USE_MATH_DEFINES
  16.  
  17. using namespace std;
  18. struct student {
  19. float body;
  20. string name;
  21. int spravna;
  22. int spatna;
  23. int nezodpovezena;
  24. };
  25.  
  26. int main()
  27. {
  28.  
  29. string radek;
  30. string soubor;
  31. string spravneOdpovedi = "AACCCCABBBBAAAAAAAAAAAAAAA";
  32.  
  33. ifstream * dokumentace = new ifstream("soubor.txt");
  34. //ifstream dokumentace("soubor.txt");
  35. if (!dokumentace->is_open())
  36. {
  37. cout << "Chyba nacteni souboru." << endl;
  38. return 0;
  39. }
  40. int studentCount = 0;
  41. int pocetRadku = 0;
  42.  
  43. int iEnd = 0;
  44. student * poleStudentu = new student[50];
  45. for (int i = 0; i < 50; i++)
  46. {
  47. poleStudentu[i].body = 0;
  48. poleStudentu[i].nezodpovezena = 0;
  49. poleStudentu[i].spatna = 0;
  50. poleStudentu[i].spravna = 0;
  51. }
  52.  
  53. while (getline(*dokumentace, radek))
  54. {
  55. studentCount++;
  56.  
  57.  
  58. //student * newPoleStudentu = new student[studentCount];
  59.  
  60.  
  61. for (int i = 0; i < studentCount; i++)
  62. {
  63.  
  64. //newPoleStudentu[i].body = 0;
  65. //newPoleStudentu[i].name = "";
  66. }
  67.  
  68. // kopirovina stareho pole do vetsiho noveho
  69. for (int i = 0; i < studentCount - 1; i++)
  70. {
  71.  
  72. //newPoleStudentu[i] = poleStudentu[i];
  73. }
  74.  
  75. //
  76. for (int i = 0; i < radek.length(); i++)
  77. {
  78. if (radek[i] == ':')
  79. {
  80. // uchovani pozice v radku
  81. iEnd = i + 2;
  82. break;
  83. }
  84. poleStudentu[studentCount - 1].name += radek[i];
  85. }
  86.  
  87. for (int j = 0; j < radek.length() - iEnd; j++)
  88. {
  89. if (radek[j + iEnd] == '0')
  90. {
  91. poleStudentu[studentCount - 1].nezodpovezena++;
  92. continue;
  93. }
  94.  
  95. if (radek[j + iEnd] == spravneOdpovedi[j])
  96. {
  97. poleStudentu[studentCount - 1].body += 1;
  98. poleStudentu[studentCount - 1].spravna++;
  99. }
  100. else
  101. {
  102. poleStudentu[studentCount - 1].body -= 0.25;
  103. poleStudentu[studentCount - 1].spatna++;
  104. }
  105. }
  106. }
  107. for (float j = 25; j >= -6.25; j-= 0.25)
  108. {
  109.  
  110. for (int i = 0; i < studentCount; i++)
  111. {
  112. if ( poleStudentu[i].body == j)
  113. {
  114. cout << poleStudentu[i].name << " pocet bodu: " << poleStudentu[i].body << " pocet spravne: " << poleStudentu[i].spravna
  115. << " pocet spatne : " << poleStudentu[i].spatna << " pocet nezodpovezenych: " << poleStudentu[i].nezodpovezena << endl;
  116. }
  117.  
  118.  
  119. }
  120. }
  121. return 0;
  122.  
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement