C언어 성적 프로그램 질문입니다!
-
게시물 수정 , 삭제는 로그인 필요
엔간하면 제 힘으로 해보려구 했는데 뭐가 잘못되었는지 잘 모르겠네요;;
갈수록 엉망이 되어가는 느낌입니다ㅜㅜ
일단 문제는 아래와 같습니다
성적 프로그램 (7점 만점)
한 반 10명의 이름, 국어, 영어, 수학 성적을 차례로 받아들여,
각 과목 성적을 90이상 A, 80점 이상 B, 70점 이상 C, 60점 이상 D, 나머지는 F를
부여하는 프로그램을 작성하시오.
또한, 이 반의 각 과목별 성적 평균과 표준 편차를 구하여 프린트하는 프로그램을
작성하시오
그래서 저는 main.c, x.c, y.c, z.c, a.c로 나누어서 프로그램을 작성했습니다
main.c는 아래와 같습니다
#include <stdio.h>
#include <math.h>
#define num 10
int record[12][5];
int grade(int n);
main()
{
record[12][5];
record[0][0] = 0;
record[0][1] = "korean";
record[0][2] = "english";
record[0][3] = "math";
record[0][4] = "total";
record[11][0] = "total";
return 0;
printf("*****************************************************************\n");
printf("This program is for calculating mean and standard deviation\n");
printf("Please notice that you can enter only 10 students' name and score\n");
printf("The score is Korean, English and Math in order.\n");
printf("*****************************************************************\n");
void RecordInput();
RecordTotal();
PrintAllData();
int grade(int n);
}
x.c는 아래와 같습니다
#include <stdio.h>
void RecordInput()
{
int record[12][5];
int i, j;
for(i = 0; i<10; i++)
{
printf("이름 먼저 입력하세요: \n", i+1);
for(j = 0; j < 1; j++)
{
scanf("%s", &record[i][j]);
}
}
for(i = 1; i < 12; i++)
{
printf("국어, 영어, 수학 성적을 입력하세요: \n", i+1);
for(j = 1; j < 4; j++)
{
scanf("%d", &record[i][j]);
}
}
}
y.c는 아래와 같습니다
#include <stdio.h>
int grade(int n) //학점 주기
{
if(n>=90)
return 'A';
else if(n>=80)
return 'B';
else if(n>=70)
return 'c';
else if(n>=60)
return 'D';
else
return 'F';
}
z.c는 아래와 같습니다
#include <stdio.h>
RecordTotal() //과목별 성적 합계
{
int record[12][5];
int i, j;
int sbj_total; // 학생별 성적 합계
for(i = 1; i<11; i++)
{
sbj_total = 0;
for(j = 1; j <4; j++)
{
sbj_total += record[j][i];
}
record[4][i] = sbj_total;
}
}
a.c는 아래와 같습니다
#include <stdio.h>
PrintAllData()
{
int record[12][5];
int i, j;
for(i = 1; i < 12; i++)
{
for(j = 1; j < 5; j++)
{
printf("M", record [i][j]);
}
printf("\n");
}
}
그래서 컴파일해보면 main.c에서
record[0][1] = "korean";
record[0][2] = "english";
record[0][3] = "math";
record[0][4] = "total";
record[11][0] = "total";
이 부분이 assignment makes integer from pointer without a cast라고 warning이 뜹니다!
다른 부분도 왠지 뭔가가 이상합니다..
특히 이름 넣는 부분에서 이름이 안 넣어지네요..
프로그램이 어디가 잘못 되었는지 고쳐주세요~
엔간하면 제 힘으로 해보려구 했는데 뭐가 잘못되었는지 잘 모르겠네요;;
갈수록 엉망이 되어가는 느낌입니다ㅜㅜ
일단 문제는 아래와 같습니다
성적 프로그램 (7점 만점)
한 반 10명의 이름, 국어, 영어, 수학 성적을 차례로 받아들여,
각 과목 성적을 90이상 A, 80점 이상 B, 70점 이상 C, 60점 이상 D, 나머지는 F를
부여하는 프로그램을 작성하시오.
또한, 이 반의 각 과목별 성적 평균과 표준 편차를 구하여 프린트하는 프로그램을
작성하시오
그래서 저는 main.c, x.c, y.c, z.c, a.c로 나누어서 프로그램을 작성했습니다
main.c는 아래와 같습니다
#include <stdio.h>
#include <math.h>
#define num 10
int record[12][5];
int grade(int n);
main()
{
record[12][5];
record[0][0] = 0;
record[0][1] = "korean";
record[0][2] = "english";
record[0][3] = "math";
record[0][4] = "total";
record[11][0] = "total";
return 0;
printf("*****************************************************************\n");
printf("This program is for calculating mean and standard deviation\n");
printf("Please notice that you can enter only 10 students' name and score\n");
printf("The score is Korean, English and Math in order.\n");
printf("*****************************************************************\n");
void RecordInput();
RecordTotal();
PrintAllData();
int grade(int n);
}
x.c는 아래와 같습니다
#include <stdio.h>
void RecordInput()
{
int record[12][5];
int i, j;
for(i = 0; i<10; i++)
{
printf("이름 먼저 입력하세요: \n", i+1);
for(j = 0; j < 1; j++)
{
scanf("%s", &record[i][j]);
}
}
for(i = 1; i < 12; i++)
{
printf("국어, 영어, 수학 성적을 입력하세요: \n", i+1);
for(j = 1; j < 4; j++)
{
scanf("%d", &record[i][j]);
}
}
}
y.c는 아래와 같습니다
#include <stdio.h>
int grade(int n) //학점 주기
{
if(n>=90)
return 'A';
else if(n>=80)
return 'B';
else if(n>=70)
return 'c';
else if(n>=60)
return 'D';
else
return 'F';
}
z.c는 아래와 같습니다
#include <stdio.h>
RecordTotal() //과목별 성적 합계
{
int record[12][5];
int i, j;
int sbj_total; // 학생별 성적 합계
for(i = 1; i<11; i++)
{
sbj_total = 0;
for(j = 1; j <4; j++)
{
sbj_total += record[j][i];
}
record[4][i] = sbj_total;
}
}
a.c는 아래와 같습니다
#include <stdio.h>
PrintAllData()
{
int record[12][5];
int i, j;
for(i = 1; i < 12; i++)
{
for(j = 1; j < 5; j++)
{
printf("M", record [i][j]);
}
printf("\n");
}
}
그래서 컴파일해보면 main.c에서
record[0][1] = "korean";
record[0][2] = "english";
record[0][3] = "math";
record[0][4] = "total";
record[11][0] = "total";
이 부분이 assignment makes integer from pointer without a cast라고 warning이 뜹니다!
다른 부분도 왠지 뭔가가 이상합니다..
특히 이름 넣는 부분에서 이름이 안 넣어지네요..
프로그램이 어디가 잘못 되었는지 고쳐주세요~