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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
| #include <iostream>
#include <stdio.h>
#include <iomanip>
#include <conio.h>
using namespace std;
struct faculty
{
char name[10];
};
struct course
{
char name[10];
};
struct group
{
char name[10];
};
struct student // студент
{
char fio[20]; // name
int facultyID; // number in the array of faculties
int courseID; // номер в масиве факультетов
int groupID; // number in the array groups
int rating[20]; // an array of ratings
};
int input(student* astudent, faculty* afaculty, int* f, course* acourse, group* agroup)
{
int c=0; // counter courses
int g=0; // counter groups
int s=0; // counter students
int r=0; // mileage ratings
char answer_faculty, answer_course, answer_group,answer_student,answer_rating; //answers to the continued cycle
do {
cout << "faculty name:"<<endl; // enter the name of the faculty
cin >> afaculty[*f].name;
do {
cout << "course name:"<<endl; // enter the name of the course
cin >> acourse[c].name;
int g=0;
do {
cout << "group name:"<<endl; // enter the name of the group
cin >> agroup[g].name;
do {
cout << "student name:"<<endl; //enter the name of the student
cin >> astudent[s].fio;
astudent[s].facultyID = *f; //number in an array of faculties
astudent[s].courseID = c; // number in an array of courses
astudent[s].groupID = g; // number in the array groups
int r=0; // mileage ratings
do {
cout << "rating:"<<endl; //introduce evaluation
cin >> astudent[s].rating[r];
if (astudent[s].rating[r]>0 && astudent[s].rating[r]<=5){ //ratings must be from 1 to 5
r++;
cout << "any rating else: (y/n)"<<endl; // request for continued input ratings
cin >> answer_rating;
}
else { // if invalid input, please repeat
answer_rating = 'y';
cout << "please enter rating from 1 to 5:"<<endl;
}
}
while(answer_rating=='y'); // check out of the loop
s++;
cout << "any student else: (y/n)"<<endl; // prompted to continue entering students
cin >> answer_student;
}
while(answer_student=='y'); // check out of the loop
g++;
cout << "any group else: (y/n)"<<endl; // request for continued group input
cin >> answer_group;
}
while(answer_group=='y'); // check out of the loop
c++;
cout << "any course else: (y/n)"<<endl; // prompted to continue entering courses
cin >> answer_course;
}
while(answer_course=='y'); // check out of the loop
*f++;
cout << "any faculty else: (y/n)"<<endl; // prompted to continue entering the faculties
cin >> answer_faculty;
}
while(answer_faculty=='y'); // check out of the loop
return (s); // return quantity of student, quantity of faculty is saved in the variable f
}
//names of students who have two or more deuces per session at the Faculty of IOT and remove them;
void student_exception(student* astudent, int s, faculty* afaculty, int f)
{
for (int i=0;i<s;i++) { // bust students
if (strcmp(afaculty[astudent[i].facultyID].name, "IOT")==0) { // found only students ІОТ
int count = sizeof(astudent[i].rating) / sizeof(astudent[i].rating[0]); // determine the size of the array count
int count2 = 0; // number twos
for (int j=0; j<count; j++){
if (astudent[i].rating[j]<=2 && astudent[i].rating[j]!=0){ // if deuce plyusuem
count2++;
}
}
if (count2>=2)
cout << "Exclude a student: " << astudent[i].fio << endl; // finding makes student output
}
}
}
//faculty that 1 course has the highest number of excellent;
void excellent_faculty(student* astudent, int s, faculty* afaculty, int f, course* acourse)
{
int facultresult[20]; // array for recording number excellent student by faculties
for (int i=0; i<f; i++) facultresult[i]=-1; //initialize it -1
int flag; // flag honors
for (int i=0;i<s;i++) { // iterate students
if (strcmp(acourse[astudent[i].courseID].name, "1")==0) { // Students find only 1 year
int count = sizeof(astudent[i].rating) / sizeof(astudent[i].rating[0]); // find the number of elements in the structure
flag = 1; //honors - check
for (int j=0; j<count; j++){ // bust estimates
if (astudent[i].rating[j]!=5 && astudent[i].rating[j]>0){ // search standouts
flag = 0; // if not honors, reset the flag honors
}
}
if (flag==1) // add the desired array Faculty
facultresult[astudent[i].facultyID]++;
}
}
int maxfacul = -1; // number of honors
int faculnum= -1; // number in an array of faculties
for (int i=0; i<f; i++){
if (facultresult[i]>maxfacul){ // if more honors
maxfacul=facultresult[i]; // save their number
faculnum = i; // save a room in an array of faculties
}
}
if (faculnum == -1) // if not found honors
cout << "Excellent student not found" << endl;
else if (maxfacul>=0)
cout << "excellent_faculty: " << afaculty[faculnum].name << endl; // derive the name of the faculty with the highest honors
}
void student_exception_course(student* astudent, int s, int f, course* acourse)
{
int courseexception[20]; // number of exceptions for courses
for (int i=0; i<f; i++) courseexception[i]=-1; // bybwbfkbpbhetv vfccbd -1
for (int i=0;i<s;i++) { // sorted of students
int count = sizeof(astudent[i].rating) / sizeof(astudent[i].rating[0]); // find the number of elements in the structure
int count2 = 0; // number of honors
for (int j=0; j<count; j++){
if (astudent[i].rating[j]<=2 && astudent[i].rating[j]!=0){ // if deuce, plus
count2++;
}
}
if (count2>=2)
courseexception[astudent[i].facultyID]++; //if two deuces student excluded - plus course
}
int maxcurs = -1; // the maximum number of excluded students on the course
int maxcursnum = -1; // number in an array of courses
for (int i=0; i<f; i++){
if (courseexception[i]>maxcurs){ // excluded if more
maxcurs=courseexception[i]; // keep the number of
maxcursnum = i; // store the number course
}
}
if (maxcurs == -1) // if not excluded
cout << "Faculty not found" << endl;
else if (maxcurs>=0)
cout << "max student exception course: " << acourse[maxcursnum].name << endl; // derive the name of the course with the maximum number of exceptions
}
void main(void)
{
faculty afaculty[100];
course acourse[100];
group agroup[100];
student astudent[100];
int s=0; // counter students
int f,t; //counter faculties
f = 0;
cout << "Create an array of structures. Each structure consists of the following elements: faculty, course, group, names of students test scores. "<< endl;
cout << "Implement queries by identifying: \n1) the names of students who have two or more deuces per session at the Faculty of BCI and remove them, "<< endl;
cout << "2) faculty, a freshman who has the most number of excellent and \n3) the course at which the greatest excluded number of students. "<< endl;
s = input(astudent, afaculty, &f, acourse, agroup);
student_exception(astudent, s, afaculty, f); //names of students who have two or more deuces per session at the Faculty of IOT and remove them;
excellent_faculty(astudent, s, afaculty, f, acourse); //faculty that a freshman has the largest number of nouns;
student_exception_course(astudent, s, f, acourse); //course at which the greatest number of students excluded.
system ("pause");
} |