@илья1995
3 / 3 / 1
Регистрация: 17.10.2011
Сообщений: 169
|
20.01.2013, 23:48
[ТС]
|
|

Сообщение от yoghurt92
илья1995, примерно так должно думаю выглядеть, не компилил, так что глянь если будут ошибки скажи...
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
| // mas1.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
#include <iostream>
#include <string.h>
using namespace std;
#define N 3
class STUDENT {
private:
char FIO[50];
int number;
int usp[5];
float sredn;
public:
STUDENT()
{
strcpy(FIO, "Petrov P.I.");
number = 4;
for(int i = 0; i < 5; i++)
usp[i] = i;
sredn = 4;
}
~STUDENT() {};
void setFIO(char *_FIO)
{
strcpy(FIO, _FIO);
}
char *getFIO(void)
{
return FIO;
}
void setnumber(int _number)
{
number = _number;
}
int getnumber(void)
{
return number;
}
void setusp(int *_usp)
{
for(int i = 0; i < 5; i++)
usp[i] = _usp[i];
}
int *getusp(void)
{
return usp;
}
void setsredn(float _sredn)
{
sredn = _sredn;
}
float getsredn(void)
{
return sredn;
}
};
int main()
{
setlocale(0, "Russian_Russia.1251");
char FIO[50];
int number, usp[5], sredn;
STUDENT clas[N];
for(int i = 0; i<N; i++)
{
cout << "Студент №" << i+1 << ":\n";
cout << "Введите фамилию и инициалы (английский): ";
cin.getline(FIO, 50);
clas[i].setFIO(FIO);
cout << "Введите номер группы: ";
cin >> number;
clas[i].setnumber(number);
cout << "Введите успеваемость (отметки): \n";
float sr=0;
for(int j=0; j<5; j++)
{
cout << j+1 << " оценка: ";
cin >> usp[j];
clas[i].setusp(usp);
sr+= usp[j];
}
sredn = sr/5;
clas[i].setsredn(sredn);
cin.ignore();
}
for(int i=0; i<N; i++)
for(int j=i+1; j<N; j++)
if(clas[i].getnumber() > clas[j].getnumber())
{
STUDENT x; x = clas[i]; clas[i] = clas[j]; clas[j] = x;
}
cout << "Студенты, у которых средний балл выше 4.0: \n";
for(int i = 0; i<N; i++)
{
if(clas[i].getsredn() > 4.0)
{
cout << "Запись №" << i << ":\n";
cout << "Студент: " << clas[i].getFIO()<< endl;
cout << "Номер группы: " << clas[i].getnumber() << endl;
cout << "Успеваемость (средний балл): " << clas[i].getsredn() << endl;
}
}
system("pause");
return 0;
} |
|
Деструктор пустой, так как поля у тебя не динамические... и члены класса желательно делать закрытыми, а методы открытыми...
скомпилировал выдало 2 ошибки но ти ошибки вроде как не в коде программы
вот они
0
|