0 / 0 / 0
Регистрация: 02.12.2016
Сообщений: 3
|
|
1
|
Добавить в программу работу с файлом
03.12.2016, 07:47. Показов 481. Ответов 0
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
| # include <iostream>
# include <string>
using namespace std;
class Students{
// установка имени студента
public:
void SetName(string student_name)
{
name=student_name;
}
//получение имени студента
string GetName()
{
return name;
}
// установка фамилии студента
void SetLastName(string student_last_name)
{
last_name=student_last_name;
}
// получение фамилии студента
string GetLastName()
{
return last_name;
}
// установка промежуточных оценок
void SetScores(int student_scores[])
{
for (int i=0;i<5;++i){
scores[i]=student_scores[i];
}
}
// считаем средний балл каждого человека
void CalcAverageBall()
{
int sum=0;
for(int i=0;i<5;i++)
{ sum+=scores[i];
}
average_ball=sum/5;
}
private:
//Промежуточные оценки
int scores[5];
//
float average_ball;
//
string name;
//
string last_name;
};
int main()
{
setlocale(0,"");
//Создание объекта класса Student
Students student;
string name;
string last_name;
int sum=0;
int n,max,min;
int scores[5];
cout<<"Введите кол-во студентов:";
cin>>n;
for (int i=0; i<n;i++){
//Ввод имени
cout<<"Name:"<<i+1<<":";
cin>>name;
//ввод фамилии
cout<<"Last name:"<<i+1<<":";
cin>>last_name;
for (int j=0; j<5;j++)
{//ввод баллов
cout<<"Score"<<j+1<<":";
cin>>scores[j];
}
//Считаем средний балл
//cout<<"Средний балл: "<<student.CalcAverageBall<<endl;
//сохранение имени и фамилии в объект класса Students
student.SetName(name);
student.SetLastName(last_name);
student.SetScores(scores);
}
system("pause");
return 0;
} |
|
0
|