This repository was archived by the owner on May 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
82 lines (71 loc) · 1.95 KB
/
main.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include <ctime>
class Student
{
int index;
int wynik1;
int wynik2;
int poprawa;
public:
void set_wynik1(int wynik1) { this->wynik1 = wynik1; }
int get_wynik1() { return this->wynik1; }
void set_wynik2(int wynik2) { this->wynik2 = wynik2; }
int get_wynik2() { return this->wynik2; }
void set_poprawa(int poprawa) { this->poprawa = poprawa; }
int get_poprawa() { return this->poprawa; }
Student(int index, int wynik1, int wynik2)
{
this->index = index;
this->wynik1 = wynik1;
this->wynik2 = wynik2;
}
};
void func(Student *students, int n)
{
int sum = 0;
for (int i = 0; i < n; i++)
{
if (students[i].get_wynik1() + students[i].get_wynik2() > 50)
{
sum += students[i].get_wynik1() + students[i].get_wynik2();
}
else
{
int max = students[i].get_wynik1() > students[i].get_wynik2() ? students[i].get_wynik1() : students[i].get_wynik2();
while (max + students[i].get_poprawa() < 51)
{
students[i].set_poprawa(rand() % 51);
}
sum += 51;
}
}
double srednia = sum / (double)n;
if (srednia > 50.0 && srednia < 60.0)
{
std::cout << "Srednia ocena - dostateczna" << std::endl;
}
else if (srednia > 60.0 && srednia <= 70.0)
{
std::cout << "Srednia ocena - dostateczna+" << std::endl;
}
else if (srednia > 70.0 && srednia <= 80.0)
{
std::cout << "Srednia ocena - dobra" << std::endl;
}
else if (srednia > 80.0 && srednia <= 90.0)
{
std::cout << "Srednia ocena - dobra+" << std::endl;
}
else
{
std::cout << "Srednia ocena - bardzo dobra" << std::endl;
}
}
int main()
{
srand(time(NULL));
const int n = 3;
Student students[n] = {Student(1, 40, 40), Student(2, 35, 35), Student(3, 40, 10)};
func(students, n);
return 0;
}