c++ 코드 질문
조회수 508회
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
struct student {
int sc[3];
int total;
double ave;
char hakhum[5];
};
int total(student stu[5], int i);
double ave(student stu[5], int i);
char hakjum(student stu[5], int i);
void main() {
int i, j;
struct student st[5];
cout << "학생의 성적을 입력하세요.\n";
for (i = 0; i < 5; i++) {
cout << i+1<<"번째 국어 영어 수학 : ";
for (j = 0; j < 3; j++)
cin >> st[i].sc[j];
}
total(st, i);
ave(st, i);
hakjum(st, i);
cout << "\n번호 국어 영어 수학 총점 평균 학점 석차";
for (i = 0; i < 5; i++) {
cout << i+1 << " " << st[i].sc[0] << " " << st[i].sc[1] << " " << st[i].sc[2] << " " << st[i].total << " " << st[i].ave<< " " << st[i].hakhum[i] << endl;
}
}
int total(student stu[5], int i) {
for (i = 0; i < 5; i++) {
stu[i].total = stu[i].sc[0] + stu[i].sc[1] + stu[i].sc[2];
}
return;
}
double ave(student stu[5], int i) {
for (i = 0; i < 5; i++) {
stu[i].ave = stu[i].total / 3.0;
}
return;
}
char hakjum(student stu[5], int i) {
int n;
for (i = 0; i < 5; i++) {
n = stu[i].ave / 10.0;
switch (n) {
case 10:
case 10:
stu[i].hakhum[i] = 'A';
break;
case 8:
stu[i].hakhum[i] = 'B';
break;
case 7:
stu[i].hakhum[i] = 'C';
break;
case 6:
stu[i].hakhum[i] = 'D';
break;
default:
stu[i].hakhum[i] = 'F';
}
return;
}
}
위의 함수들을 반환할려고 할때 어떻게 반환 시켜야 하나요?
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
댓글 입력