#include <stdio.h>
// #include "myheader.h"
int main(void) {
// 변수선언
int s[3][4];
char name[3][9];
int sum[3];
double avg[3];
char grade[3];
int i;
int choice;
while(1) {
choice = menu();
switch(choice) {
case 1: input_data(s, name, 3); break;
case 2: check_data(s, name, 3); break;
case 3: calculate_data(s, sum, avg, grade, 3); break;
case 4: print_data(s, name, sum, avg, grade, 3); break;
case 5: search_id(s, size); break;
case 6: sort_id(s, name, sum, avg, grade, 3); break;
case 0: return 0;
default:
break;
}
}
}
double calculate_avg(int kor, int eng, int math) {
int sum;
double avg;
sum = kor + eng + math;
avg = (double) sum / 3;
return avg;
}
char calculate_grade(double avg) {
char grade;
if (avg >= 90) grade = 'A';
else if(avg >= 80) grade = 'B';
else if(avg >= 70) grade = 'C';
else if(avg >= 60) grade = 'D';
else grade = 'F';
return grade;
}
void input_data(int (*ps)[4], char (*pname)[9], int size) {
int i;
for (i = 0; i < size; i++) {
scanf("%d", &ps[i][0]);
scanf("%s", pname[i]);
scanf("%d%d%d", &ps[i][1], &ps[i][2], &ps[i][3]);
}
}
void calculate_data(int (*ps)[4], int *psum, doulbe *pavg, char *pgrade, int size) {
int i;
for (i = 0; i < size; i++) {
psum[i] = ps[i][1] + ps[i][2] + ps[i][3];
pavg[i] = calculate_avg(ps[i][1], ps[i][2], ps[i][3]);
pgrade[i] = calculate_grade(pavg[i]);
}
}
void print_data(int (*ps)[4], char (*pname)[9], int *psum, doulbe *pavg, char *pgrade, int size) {
int i;
printf("학번 이 름 국어 영어 수학 총점 평균 학점\n");
for (i = 0; i < size; i++) {
printf("%4d %8s %4d %4d %4d %4d %4.1f %4c\n",
ps[i][0], pname[i], ps[i][1], ps[i][2], ps[i][3], psum[i], pavg[i], pgrade[i]);
}
}
void check_data(int (*ps)[4], char (*pname)[9], int size) {
int i;
printf("학번 이 름 국어 영어 수학\n");
for (i = 0; i < size; i++) {
printf("%4d %8s %4d %4d %4d\n",
ps[i][0], pname[i], ps[i][1], ps[i][2], ps[i][3]);
}
}
--------------------Configuration: 00000 - Win32 Debug--------------------
Compiling...
543.cpp
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(15) : error C2065: 'menu' : undeclared identifier
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(17) : error C2065: 'input_data' : undeclared identifier
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(18) : error C2065: 'check_data' : undeclared identifier
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(19) : error C2065: 'calculate_data' : undeclared identifier
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(20) : error C2065: 'print_data' : undeclared identifier
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(21) : error C2065: 'search_id' : undeclared identifier
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(21) : error C2065: 'size' : undeclared identifier
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(22) : error C2065: 'sort_id' : undeclared identifier
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(52) : error C2373: 'input_data' : redefinition; different type modifiers
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(61) : error C2065: 'ps' : undeclared identifier
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(61) : error C2100: illegal indirection
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(61) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(61) : error C2062: type 'int' unexpected
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(61) : error C2143: syntax error : missing ';' before '{'
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(61) : error C2447: missing function header (old-style formal list?)
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(70) : error C2100: illegal indirection
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(70) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(70) : error C2065: 'pname' : undeclared identifier
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(70) : error C2100: illegal indirection
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(70) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(70) : error C2062: type 'int' unexpected
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(70) : error C2143: syntax error : missing ';' before '{'
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(70) : error C2447: missing function header (old-style formal list?)
C:\Documents and Settings\MyHome\바탕 화면\00000\543.cpp(79) : error C2373: 'check_data' : redefinition; different type modifiers
Error executing cl.exe.
00000.exe - 24 error(s), 0 warning(s)
-------
변수선언이 잘못되있다고 하는거 같은데 못찾겠네요 ㅠㅠ
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.