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
|
#include <iostream>
using namespace std;
void input(char *name, int *score, int num);
void oper(int *score, float *avg, int num);
void output(char *name, int *score, float *avg, int num);
int main() {
//name kor math eng average
int num;
char *name;
int *score;
float *avg;
cout << "몇 사람 :";
cin >> num;
name = new char[num * 10];
score = new int[num * 4];
avg = new float[num];
input(name, score, num);
oper(score, avg, num);
output(name, score, avg, num);
delete[]name;
delete[]score;
delete[]avg;
}
void input(char *name, int *score, int num) {
int i, j;
for (i = 0; i < num; i++) {
cout << "Name intput :";
cin >> name;
for (j = 0; j < 3; j++)
{
if (j == 0) cout << "Kor input :";
else if (j == 1) cout << "Eng input :";
else cout << "Math input :";
cin >> score[j];
}
name += 10;
score += 4;
}
}
void oper(int *score, float *avg, int num) {
int i, j;
for (j = 0; j < num; j++){
*(score+3) = 0;
for ( i = 0; i < 3; i++)
{
*(score+3) += *(score+i);
}
*avg = *(score+3) / 3.f;
score += 4;
avg++;
}
}
void output(char *name, int *score, float *avg, int num) {
int i, j;
system ("cls");
for ( i = 0; i < num; i++)
{
cout << name << "\t ";
for ( j = 0; j < 4; j++)
{
cout << *(score+j)<<"\t ";
}
cout << *avg<<endl;
name += 10;
score += 4;
avg++;
}
}
|
cs |
'Programming > [C++]' 카테고리의 다른 글
[C++] Template 함수 (템플릿 함수) (0) | 2018.03.21 |
---|---|
[C++] Template Class (템플릿 클래스) (0) | 2018.03.21 |
[C++] Static (스태틱) (0) | 2018.03.21 |
[C++] 스택, 큐 메모리 템플릿 (Stack, Queue Memory Template) (0) | 2018.03.21 |
[C++] Reference(레퍼런스) (0) | 2018.03.21 |