Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. //Stepien
  4. class Obecnosc
  5. {
  6. private:
  7. int *tablica;
  8.  
  9. public:
  10. Obecnosc();
  11. ~Obecnosc();
  12. int dzien;
  13. void sprawdz_obecnosc();
  14. int get_obecnosc(int n);
  15. void set_obecnosc(int n, int x);
  16. double fekwencja();
  17. int licz_usprawiedliwione();
  18. int licz_spoznienia();
  19. };
  20.  
  21. int main()
  22. {
  23.  
  24.  
  25. return 0;
  26. }
  27. Obecnosc:: Obecnosc()
  28. {
  29. tablica = new int[31];
  30. for(int i=0; i<31; i++)
  31. tablica[i] = 0;
  32. }
  33.  
  34. Obecnosc:: ~Obecnosc()
  35. {
  36. }
  37.  
  38. void Obecnosc::sprawdz_obecnosc()
  39. {
  40. int x = 0;
  41. cout << "Czy uczen jest obecny? (4-tak, 1-nie, 2-spozniony, 3-usprawiedliwiony)";
  42. cin >> x;
  43. for(int i = 0; i < 31; i++)
  44. {
  45. if(tablica[i]==0)
  46. {
  47. tablica[i] = x;
  48. break;
  49. }
  50. }
  51. }
  52.  
  53. int Obecnosc::get_obecnosc(int n)
  54. {
  55. return tablica[n];
  56. }
  57.  
  58. void Obecnosc::set_obecnosc(int n, int x)
  59. {
  60. tablica[n] = x;
  61. }
  62.  
  63. double Obecnosc::fekwencja()
  64. {
  65. int ile_nb = 0, ile_zer = 0;
  66. for(int i=0; i<31; i++)
  67. {
  68. if(tablica[i]==1)
  69. {
  70. ile_nb++;
  71. }
  72. if(tablica[i] == 0)
  73. {
  74. ile_zer++;
  75. }
  76. }
  77. return ((31-ile_zer-ile_nb)/31-ile_zer);
  78. }
  79.  
  80. int Obecnosc::licz_usprawiedliwione()
  81. {
  82. int ile_usp=0;
  83. for(int i=0; i<31; i++)
  84. {
  85. if(tablica[i]==3)
  86. {
  87. ile_usp++;
  88. }
  89. }
  90. return ile_usp;
  91. }
  92.  
  93. int Obecnosc::licz_spoznienia()
  94. {
  95. int ile_spz=0;
  96. for(int i=0; i<31; i++)
  97. {
  98. if(tablica[i]==3)
  99. {
  100. ile_spz++;
  101. }
  102. }
  103. return ile_spz;
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement