임의의 학생을 입력받아 성적, 최고,최저학생을 나타내는 코드 수정좀 부탁드려요 ㅠㅠ
다옴
질문 제목 : 임의의 학생을 입력받아 성적, 최고,최저학생을 나타내는 코드 수정코드는 맞는거 같기도 한데(디버깅시 오류는 없습니다), 실행해보면 이상한 문자가 나타나네요 ㅠㅠ질문 내용 :
#includestdio.h
#includemalloc.h
#includestring.h
int main(void)
{
int students, s, engsum=0, korsum=0, mathsum=0, max=0, min=0;
int *engscore=null;
int *korscore=null;
int *mathscore=null;
char *name=null;
printf(성적을 처리할 학생 수를 입력하세요:);
scanf(%d,&students);
engscore=(int*)malloc(sizeof(int)*students);
korscore=(int*)malloc(sizeof(int)*students);
mathscore=(int*)malloc(sizeof(int)*students);
name=(char*)malloc(sizeof(int)*students);
printf(학생의 이름과 성적을 입력하세요\n);
for(s=0 ; sstudents ; s++)
{
printf(%d번 이름: (영어 국어 수학):,s+1);
scanf(%c %d %d %d,&name[s],&engscore[s],&korscore[s],&mathscore[s]);
}
printf(-----------------------\n);
for(s=0 ; sstudents ; s++)
{
engsum += engscore[s];
korsum += korscore[s];
mathsum += mathscore[s];
printf(%d번 이름:%c 영어:%d 국어:%d 수학:%d\n,s+1,name[s],engscore[s],korscore[s],mathscore[s]);
}
for(s=0 ; sstudents ; s++)
{
if(max engscore[s]+korscore[s]+mathscore[s])
max=engscore[s]+korscore[s]+mathscore[s];
printf(최고점학생은 %c 총점은 %3d 평균은 %3.2d\n,name[s],max,max/students);
if(min engscore[s]+korscore[s]+mathscore[s])
min=engscore[s]+korscore[s]+mathscore[s];
printf(최저점학생은 %c 총점은 %3d 평균은 %3.2d\n,name[s],min,min/students);
}
printf(-----------------------\n);
printf(영어총점:%3d점\n,engsum);
printf(영어평균:%3.2점\n,(double)engsum/students);
printf(국어총점:%3d점\n,korsum);
printf(국어평균:%3.2점\n,(double)korsum/students);
printf(수학총점:%3d점\n,mathsum);
printf(수학평균:%3.2점\n,(double)mathsum/students);
free(engscore);
free(korscore);
free(mathscore);
free(name);
return 0;
}어디어디를 뜯어 고쳐야 올바르게 나올까요 ㅠㅠ
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2692230 | 하노이탑 질문입니다. (1) | 미쁘다 | 2025-04-21 |
2692210 | 정보 올림피아드 문제인데.. 풀이 과정이 궁금합니다.(재귀함수) (5) | 물티슈 | 2025-04-20 |
2692144 | C언어와 리눅스에 대한 질문입니다. | 싴흐한세여니 | 2025-04-20 |
2692114 | 컨텍스트 스위칭하는데 걸리는 시간 측정.. | YourWay | 2025-04-19 |
2692086 | 간접참조 연산자, 증감연산자 질문이용! (2) | 블랙캣 | 2025-04-19 |
2692056 | 주석좀 달아주세요. 몇개적엇는데 몇개만달아주세요. (2) | DevilsTears | 2025-04-19 |
2691978 | 진수 쉽게 이해하는법... (3) | 지지않는 | 2025-04-18 |
2691949 | getchar() 한 문자를 입력받는 함수 질문 | 채꽃 | 2025-04-18 |
2691919 | 배열 정렬 및 합치기 질문입니다. | 사과 | 2025-04-18 |
2691845 | c언어왕초보 질문이 있습니다........ | 루나 | 2025-04-17 |
2691815 | void add(int num); 함수... (4) | 살랑살랑 | 2025-04-17 |
2691756 | 명령 프롬프트 스크롤바가 없어요 | 두메꽃 | 2025-04-16 |
2691725 | 자료구조에 관련해서 질문이 있어 글을 올립니다. | 누리알찬 | 2025-04-16 |
2691697 | if 문에서 구조체 배열에 저장되있던 문자열 검사하는 법 ? (2) | 민트맛사탕 | 2025-04-16 |
2691678 | C언어 함수 질문이요~!!! | 연보라 | 2025-04-15 |
2691650 | 반복문 | 돋가이 | 2025-04-15 |
2691618 | 링크드리스트 개념 질문이예요 (3) | 맨마루 | 2025-04-15 |
2691592 | 동적할당 이용 배열선언 질문입니다.ㅠㅠ (3) | 허리달 | 2025-04-15 |
2691542 | /=의 용도를 알려주세요 ㅠㅠ! (2) | 아라 | 2025-04-14 |
2691510 | sizeof 연산자 질문입니다 (2) | 종달 | 2025-04-14 |