да! я уже как раз это поняла ))
только теперь не знаю куда ее вставить..
вот программа
может будет непонятно потому что она чуток на другом языке)) но факт в том что первой должна выполняться команда там где menu.. как теперь туда вставить main?
C++ | 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
204
205
206
207
208
209
210
211
212
213
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct student {
char am[7]; /*AM tou foithth */
float final_grade; /*telikos bathmos*/
float exam_grade; /*bathmos ths eksetashs*/
float essay_grade; /*bathmos ths ergasias*/
} pupil[100];
struct exam_question {
char erwtisi[100]; /*erwtiseis*/
char apantisi1[50]; /*pithanh apanthsh 1*/
char apantisi2 [50]; /*pithanh apanthsh 2*/
char apantisi3 [50]; /*pithanh apanthsh 3*/
int swsti_apantisi; /*arithmos swsths apanthshs*/
} erwtiseis[3];
int current = 0; /*o arithmos twn foithtwn pou eisagontai sto susthma*/
void pinakas_erwthsewn(void) { /*erwtiseis*/
strcpy(erwtiseis[0].apantisi1, "Xerox");
strcpy(erwtiseis[0].apantisi2, "Apple");
strcpy(erwtiseis[0].apantisi3, "IBM");
strcpy(erwtiseis[0].erwtisi, "Apo poia etairia anaptithhke h glwssa FORTRAN?"); /*erwtisi 1*/
erwtiseis[0].swsti_apantisi = 3;
strcpy(erwtiseis[1].apantisi1, "Pascal");
strcpy(erwtiseis[1].apantisi2, "Cobol");
strcpy(erwtiseis[1].apantisi3, "SQL");
strcpy(erwtiseis[1].erwtisi, "Poia apo tis parakatw glwsses einai h glwssa polu upsilou epipedou?"); /*erwtisi 2*/
erwtiseis[1].swsti_apantisi = 3;
strcpy(erwtiseis[2].apantisi1, "ROM");
strcpy(erwtiseis[2].apantisi2, "CD");
strcpy(erwtiseis[2].apantisi3, "DRAM");
strcpy(erwtiseis[2].erwtisi, "Poia apo tis parakatw mnhmes einai astathhs?"); /*erwtisi 3*/
erwtiseis[2].swsti_apantisi = 3;
strcpy(erwtiseis[3].apantisi1, "2^(n+1)");
strcpy(erwtiseis[3].apantisi2, "2^n");
strcpy(erwtiseis[3].apantisi3, "2^(n-1)");
strcpy(erwtiseis[3].erwtisi, "Posous pithanous sunduasmous timwv eisodou mporei na exei mia sunarthsh Boole me n metablites?"); /*erwtisi 4*/
erwtiseis[3].swsti_apantisi = 2;
}
int checkAM(char *amToCheck) /*na elegxoume an AM hdh uparxei sto susthma h oxi*/ {
int check1 = 0; /*ean o AM den uparxei*/
for (int i = 0; i < current; i++) {
if (strcmp(amToCheck, pupil[i].am) == 0) {
check1 = -1; /*ean o AM hdh uparxei*/
break;
}
}
return check1;
}
void Eksetash(void) {
int erwt1 = rand() % 4; /*gia na emfanizontai tuxaia oi erwtiseis*/
int erwt2, erwt3, erwt4;
do {
erwt2 = rand() % 4;
} while (erwt1 == erwt2);
do {
erwt3 = rand() % 4;
} while (erwt1 == erwt3 || erwt2 == erwt3);
do {
erwt4 = rand() % 4;
} while (erwt1 == erwt4 || erwt2 == erwt4 || erwt3 == erwt4);
printf("Grapste ton AM sas\n");
char AM [7];
scanf("%s", &AM);
int found = checkAM(AM);
if (found == -1) {
printf("Exete hdh extastei. Exit");
} else {
strcpy(pupil[current].am,AM);
do {
printf("Grapste ton bathmo ergasias sas\n");
scanf("%f", &pupil[current].essay_grade);
} while (pupil[current].essay_grade < 0 || pupil[current].essay_grade > 10);
current++;
}
int apantisi = 0;
int count = 0;
printf("%s\n", erwtiseis[erwt1].erwtisi);
printf("1.%s\n", erwtiseis[erwt1].apantisi1);
printf("2.%s\n", erwtiseis[erwt1].apantisi2);
printf("3.%s\n", erwtiseis[erwt1].apantisi3);
scanf("%d", &apantisi);
if (apantisi == erwtiseis [erwt1].swsti_apantisi) {
count++;
}
printf("%s\n", erwtiseis[erwt2].erwtisi);
printf("1.%s\n", erwtiseis[erwt2].apantisi1);
printf("2.%s\n", erwtiseis[erwt2].apantisi2);
printf("3.%s\n", erwtiseis[erwt2].apantisi3);
scanf("%d", &apantisi);
if (apantisi == erwtiseis[erwt2]. swsti_apantisi) {
count++;
}
printf("%s\n", erwtiseis[erwt3]. erwtisi);
printf("1.%s\n", erwtiseis[erwt3].apantisi1);
printf("2.%s\n", erwtiseis[erwt3].apantisi2);
printf("3.%s\n", erwtiseis[erwt3].apantisi3);
scanf("%d", &apantisi);
if (apantisi == erwtiseis[erwt3]. swsti_apantisi) {
count++;
}
printf("%s\n", erwtiseis[erwt4]. erwtisi);
printf("1.%s\n", erwtiseis[erwt4].apantisi1);
printf("2.%s\n", erwtiseis[erwt4].apantisi2);
printf("3.%s\n", erwtiseis[erwt4].apantisi3);
scanf("%d", &apantisi);
if (apantisi == erwtiseis[erwt4]. swsti_apantisi) {
count++;
}
pupil[found].exam_grade = count * 2, 5; /*metrhsh bathmou eksetashs*/
pupil[found].final_grade = 0.75 * pupil[found].exam_grade + 0.25 * pupil[found].essay_grade; /*metrhsh telikou bathmou*/
}
void Anazhthsh_kai_ektupwsh_bathmou() {
printf("Grapste AM tou foithth: \n ");
char AM [7];
scanf("%s", &AM);
for (int i = 0; i < current; i++) {
if (strcmp(AM, pupil[i].am) == 0) {
printf("AM:%s\n\n", pupil[i].am);
printf("Essay grade:%f\n", pupil[i].essay_grade);
printf("Exam grade:%f\n", pupil[i].exam_grade);
printf("Final Grade:%f\n\n", pupil[i].final_grade);
break;
}
}
}
void Ektupwsh_telikhs_listas_bathmologias(void) {
for (int counter = 0; counter < current; counter++) {
printf("AM:%s\n\n", pupil[counter].am);
printf("Essay grade:%f\n", pupil[counter].essay_grade);
printf("Exam grade:%f\n", pupil[counter].exam_grade);
printf("Final Grade:%f\n\n", pupil[counter].final_grade);
}
printf("\n\n");
}
void Statistika_stoixeia(void) {
int arithmos_epituxontwn = 0;
for (int counter = 0; counter < current; counter++) {
if (pupil[counter].final_grade >= 5) {
arithmos_epituxontwn++;
}
}
float pososto_epituxontwn = (arithmos_epituxontwn / current)*100;
printf("O arithmos twn epituxontwn einai %d\n", arithmos_epituxontwn);
printf("To pososto twn epituxontwn einai %f\n\n %", pososto_epituxontwn);
}
int menu(void) {
printf("\n\n\t1:Eksetash");
printf("\n\t\t2:Anazhthsh kai ektupwsh bathmou");
printf("\n\t\t3:Ektupwsh telikhs listas bathmologias");
printf("\n\t\t4:Statistika stoixeia");
printf("\n\t\t5:Eksodos\n");
int c = 0;
scanf("%d", &c);
do {
c = menu();
if (c > 0 || c < 5) {
switch (c) {
case 1:
Eksetash();
break;
case 2:
Anazhthsh_kai_ektupwsh_bathmou();
break;
case 3:
Ektupwsh_telikhs_listas_bathmologias();
break;
case 4:
Statistika_stoixeia();
break;
}
}
}while(c!=5);
return c;
} |
|
Добавлено через 2 минуты
вот я поставила main вместо menu, но теперь программа работает неправильно, потому что не возвращает пользователя в меню после выбора пункта
C++ | 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct student
{
char am[7]; /*AM tou foithth */
float final_grade; /*telikos bathmos*/
float exam_grade; /*bathmos ths eksetashs*/
float essay_grade; /*bathmos ths ergasias*/
}
pupil[100];
struct exam_question
{
char erwtisi[100]; /*erwtiseis*/
char apantisi1[50]; /*pithanh apanthsh 1*/
char apantisi2 [50]; /*pithanh apanthsh 2*/
char apantisi3 [50]; /*pithanh apanthsh 3*/
int swsti_apantisi; /*arithmos swsths apanthshs*/
}
erwtiseis[4];
int current = 0; /*o arithmos twn foithtwn pou eisagontai sto susthma*/
void pinakas_erwthsewn(void)
{ /*erwtiseis*/
strcpy(erwtiseis[0].apantisi1, "Xerox");
strcpy(erwtiseis[0].apantisi2, "Apple");
strcpy(erwtiseis[0].apantisi3, "IBM");
strcpy(erwtiseis[0].erwtisi, "Apo poia etairia anaptithhke h glwssa FORTRAN?"); /*erwtisi 1*/
erwtiseis[0].swsti_apantisi = 3;
strcpy(erwtiseis[1].apantisi1, "Pascal");
strcpy(erwtiseis[1].apantisi2, "Cobol");
strcpy(erwtiseis[1].apantisi3, "SQL");
strcpy(erwtiseis[1].erwtisi, "Poia apo tis parakatw glwsses einai h glwssa polu upsilou epipedou?"); /*erwtisi 2*/
erwtiseis[1].swsti_apantisi = 3;
strcpy(erwtiseis[2].apantisi1, "ROM");
strcpy(erwtiseis[2].apantisi2, "CD");
strcpy(erwtiseis[2].apantisi3, "DRAM");
strcpy(erwtiseis[2].erwtisi, "Poia apo tis parakatw mnhmes einai astathhs?"); /*erwtisi 3*/
erwtiseis[2].swsti_apantisi = 3;
strcpy(erwtiseis[3].apantisi1, "2^(n+1)");
strcpy(erwtiseis[3].apantisi2, "2^n");
strcpy(erwtiseis[3].apantisi3, "2^(n-1)");
strcpy(erwtiseis[3].erwtisi, "Posous pithanous sunduasmous timwv eisodou mporei na exei mia sunarthsh Boole me n metablites?"); /*erwtisi 4*/
erwtiseis[3].swsti_apantisi = 2;
}
int checkAM(char *amToCheck) /*na elegxoume an AM hdh uparxei sto susthma h oxi*/
{
int check1 = 0; /*ean o AM den uparxei*/
for (int i = 0; i < current; i++)
{
if (strcmp(amToCheck, pupil[i].am) == 0)
{
check1 = -1; /*ean o AM hdh uparxei*/
break;
}
}
return check1;
}
void Eksetash(void)
{
int erwt1 = rand() % 4; /*gia na emfanizontai tuxaia oi erwtiseis*/
int erwt2, erwt3, erwt4;
do
{
erwt2 = rand() % 4;
}
while (erwt1 == erwt2);
do
{
erwt3 = rand() % 4;
}
while (erwt1 == erwt3 || erwt2 == erwt3);
do
{
erwt4 = rand() % 4;
}
while (erwt1 == erwt4 || erwt2 == erwt4 || erwt3 == erwt4);
printf("Grapste ton AM sas\n");
char AM [7];
scanf("%s", &AM);
int found = checkAM(AM);
if (found == -1)
{
printf("Exete hdh extastei. Exit");
}
else
{
strcpy(pupil[current].am,AM);
do
{
printf("Grapste ton bathmo ergasias sas\n");
scanf("%f", &pupil[current].essay_grade);
}
while (pupil[current].essay_grade < 0 || pupil[current].essay_grade > 10);
current++;
}
int apantisi = 0;
int count = 0;
printf("%s\n", erwtiseis[erwt1].erwtisi);
printf("1.%s\n", erwtiseis[erwt1].apantisi1);
printf("2.%s\n", erwtiseis[erwt1].apantisi2);
printf("3.%s\n", erwtiseis[erwt1].apantisi3);
scanf("%d", &apantisi);
if (apantisi == erwtiseis [erwt1].swsti_apantisi)
{
count++;
}
printf("%s\n", erwtiseis[erwt2].erwtisi);
printf("1.%s\n", erwtiseis[erwt2].apantisi1);
printf("2.%s\n", erwtiseis[erwt2].apantisi2);
printf("3.%s\n", erwtiseis[erwt2].apantisi3);
scanf("%d", &apantisi);
if (apantisi == erwtiseis[erwt2]. swsti_apantisi)
{
count++;
}
printf("%s\n", erwtiseis[erwt3]. erwtisi);
printf("1.%s\n", erwtiseis[erwt3].apantisi1);
printf("2.%s\n", erwtiseis[erwt3].apantisi2);
printf("3.%s\n", erwtiseis[erwt3].apantisi3);
scanf("%d", &apantisi);
if (apantisi == erwtiseis[erwt3]. swsti_apantisi)
{
count++;
}
printf("%s\n", erwtiseis[erwt4]. erwtisi);
printf("1.%s\n", erwtiseis[erwt4].apantisi1);
printf("2.%s\n", erwtiseis[erwt4].apantisi2);
printf("3.%s\n", erwtiseis[erwt4].apantisi3);
scanf("%d", &apantisi);
if (apantisi == erwtiseis[erwt4]. swsti_apantisi)
{
count++;
}
pupil[found].exam_grade = count * 2, 5; /*metrhsh bathmou eksetashs*/
pupil[found].final_grade = 0.75 * pupil[found].exam_grade + 0.25 * pupil[found].essay_grade; /*metrhsh telikou bathmou*/
}
void Anazhthsh_kai_ektupwsh_bathmou()
{
printf("Grapste AM tou foithth: \n ");
char AM [7];
scanf("%s", &AM);
for (int i = 0; i < current; i++)
{
if (strcmp(AM, pupil[i].am) == 0)
{
printf("AM:%s\n\n", pupil[i].am);
printf("Essay grade:%f\n", pupil[i].essay_grade);
printf("Exam grade:%f\n", pupil[i].exam_grade);
printf("Final Grade:%f\n\n", pupil[i].final_grade);
break;
}
}
}
void Ektupwsh_telikhs_listas_bathmologias(void)
{
for (int counter = 0; counter < current; counter++)
{
printf("AM:%s\n\n", pupil[counter].am);
printf("Essay grade:%f\n", pupil[counter].essay_grade);
printf("Exam grade:%f\n", pupil[counter].exam_grade);
printf("Final Grade:%f\n\n", pupil[counter].final_grade);
}
printf("\n\n");
}
void Statistika_stoixeia(void)
{
int arithmos_epituxontwn = 0;
for (int counter = 0; counter < current; counter++)
{
if (pupil[counter].final_grade >= 5)
{
arithmos_epituxontwn++;
}
}
float pososto_epituxontwn = (arithmos_epituxontwn / current)*100;
printf("O arithmos twn epituxontwn einai %d\n", arithmos_epituxontwn);
printf("To pososto twn epituxontwn einai %f\n\n %", pososto_epituxontwn);
}
int main (void)
{
printf("\n\n\t1:Eksetash");
printf("\n\t\t2:Anazhthsh kai ektupwsh bathmou");
printf("\n\t\t3:Ektupwsh telikhs listas bathmologias");
printf("\n\t\t4:Statistika stoixeia");
printf("\n\t\t5:Eksodos\n");
int c = 0;
scanf("%d", &c);
do
{
if (c > 0 || c < 5)
{
switch (c)
{
case 1:
Eksetash();
break;
case 2:
Anazhthsh_kai_ektupwsh_bathmou();
break;
case 3:
Ektupwsh_telikhs_listas_bathmologias();
break;
case 4:
Statistika_stoixeia();
break;
}
}
}
while(c>5);
return c;
} |
|
0
|