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
|
#include <iostream>
#include <string>
using namespace std;
class Name {
string name;
public :
void setN(string name) {
this->name = name;
}
string getN() {
return name;
}
};
class subject {
int KorScore;
int MathScore;
int EngScore;
public:
void setSK(int KorScore) {
this -> KorScore = KorScore;
}
int getSK() {
return KorScore;
}
void setSM(int MathScore) {
this->MathScore = MathScore;
}
int getSM() {
return MathScore;
}
void setSE(int EngScore) {
this->EngScore = EngScore;
}
int getSE() {
return EngScore;
}
};
class subjectManager {
Name nn;
subject ss;
string name;
int KorScore;
int MathScore;
int EngScore;
int sum;
float avr;
public:
void setN(string name) {
nn.setN(name);
}
string getN() {
return nn.getN();
}
void setSK(int KorScore) {
ss.setSK(KorScore);
}
int getSK() {
return ss.getSK();
}
void setSM(int MathScore) {
ss.setSM(MathScore);
}
int getSM() {
return ss.getSM();
}
void setSE(int EngScore) {
ss.setSE(EngScore);
}
int getSE() {
return ss.getSE();
}
void setScore(int sum) {
this->sum = sum;
}
int getScore() {
sum = ss.getSE() + ss.getSK() + ss.getSM();
return sum;
}
float getAvr(float avr) {
this->avr = avr;
}
float getAvr() {
avr = sum / 3;
return avr;
}
};
void main() {
int num;
string name;
int i;
int KorScore;
int MathScore;
int EngScore;
cout << "몇 명" << endl;
cin >> num;
subjectManager *sm = new subjectManager[num];
for ( i = 0; i < num; i++)
{
cout << "이름" << endl;
cin >> name;
sm[i].setN(name);
cout << "국어" << endl;
cin >> KorScore;
sm[i].setSK(KorScore);
cout << "수학" << endl;
cin >> MathScore;
sm[i].setSM(MathScore);
cout << "영어" << endl;
cin >> EngScore;
sm[i].setSE(EngScore);
}
for ( i = 0; i < num; i++)
{
cout << "이름 :" << sm[i].getN() << endl;
cout << "국어 :" << sm[i].getSK() << endl;
cout << "수학 :" << sm[i].getSM() << endl;
cout << "영어 :" << sm[i].getSE() << endl;
cout << "총점 :" << sm[i].getScore() << endl;
cout << "평균 :" << sm[i].getAvr() << endl;
}
delete sm;
}
|
cs |
'Programming > [C++]' 카테고리의 다른 글
[C++] 연산자 함수를 만들지 못하는 연산자의 종류 (0) | 2018.03.20 |
---|---|
[C++] 동적 바인딩의 순수 추상 함수(Stack, Queue Memory 스택, 큐 메모리) 동적바인딩 (0) | 2018.03.20 |
[C++]접근지정자 public, protected, private (0) | 2018.03.20 |
[C++]성적 처리 프로그램 기초 (0) | 2018.03.20 |
[C++]setw란??? (0) | 2018.03.20 |