FSHY include stdafx include iostream include conio using namespace std

 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
// FSHY
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;
struct student
{
char name[15];
int group;
int balls[5];
};
float Average(int[5]);
void setArr(student[10]);
int _tmain(int argc, _TCHAR* argv[])
{
student array[10];
setArr(array);
for (int i = 0; i < 10; i++)
{
if (Average(array[i].balls) > 4.0)
cout << endl << array[i].name << " " << array[i].group;
}
_getch();
return 0;
}
float Average(int n[5])
{
int av = 0;
for (int i = 0; i < 5; i++)
{
av += n[i];
}
return av / 5;
}
void setArr(student a[10])
{
for (int i = 0; i < 10; i++)
{
cout << "\nNAME = ";
cin >> a[i].name;
cout << "\nGROUP = ";
cin >> a[i].group;
cout << "\nEnter balls:";
for (int i = 0; i < 5; i++)
{
cout << "\n\t[" << i+1 << "] = ";
cin >> a[i].balls[i];
}
cout << endl << endl;
}
}