#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
struct student {
char name[10];
double bunho;
int math;
int korean;
int english;
int science;
int society;
int sum;
int avr;
};
struct temp {
char name[10];
double bunho;
int math;
int korean;
int english;
int science;
int society;
int sum;
int avr;
};
int main()
{
puts(\" \");
puts(\"최대 100명의 성적을 입출력합니다\");
puts(\"아무 키나 눌러주세요\");
getch();
system(\"cls\");
int num;
puts(\"\");
printf(\"총 학생 수를 입력하세요 : \");
scanf(\"%d\", &num);
struct student stu[100];
struct temp tmp[1];
int i;
for(i=0; i<num; i++)
{
puts(\" \");
printf(\"%d번째 학생의 이름을 입력하세요 : \", i+1);
scanf(\"%s\", &stu[i].name);
printf(\"%d번째 학생의 학번을 입력하세요 : \", i+1);
scanf(\"%d\", &stu[i].bunho);
printf(\"%d번째 학생의 수학성적을 입력하세요 : \", i+1);
scanf(\"%d\", &stu[i].math);
printf(\"%d번째 학생의 국어성적을 입력하세요 : \", i+1);
scanf(\"%d\", &stu[i].korean);
printf(\"%d번째 학생의 영어성적을 입력하세요 : \", i+1);
scanf(\"%d\", &stu[i].english);
printf(\"%d번째 학생의 과학성적을 입력하세요 : \", i+1);
scanf(\"%d\", &stu[i].science);
printf(\"%d번째 학생의 사회성적을 입력하세요 : \", i+1);
scanf(\"%d\", &stu[i].society);
puts(\" \");
}
puts(\"\");
printf(\"총 %d명의 학생성적을 입력받았습니다\\n\", num);
puts(\"아무 키나 눌러주세요\");
getch();
system(\"cls\");
for(i=0; i<num; i++);
{
stu[i].sum = stu[i].english + stu[i].korean + stu[i].math + stu[i].science + stu[i].society;
stu[i].avr = stu[i].science / 5;
}
int j;
int one;
int two;
int pl;
for(i=0; i<num; i++)
{
for(j=0; j<num-1; j++)
{
pl = j + 1;
one = stu[j].avr;
two = stu[pl].avr;
if(one <= two)
{
tmp[1].name[10] = stu[j].name[10];
tmp[1].bunho = stu[j].bunho;
tmp[1].english = stu[j].english;
tmp[1].korean = stu[j].korean;
tmp[1].math = stu[j].math;
tmp[1].science = stu[j].science;
tmp[1].society = stu[j].society;
tmp[1].sum = stu[j].sum;
tmp[1].avr = stu[j].avr;
stu[j].name[10] = stu[pl].name[10];
stu[j].bunho = stu[pl].bunho;
stu[j].english = stu[pl].english;
stu[j].korean = stu[pl].korean;
stu[j].math = stu[pl].math;
stu[j].science = stu[pl].science;
stu[j].society = stu[pl].society;
stu[j].sum = stu[pl].sum;
stu[j].avr = stu[pl].avr;
stu[pl].name[10] = tmp[1].name[10];
stu[pl].bunho = tmp[1].bunho;
stu[pl].english = tmp[1].english;
stu[pl].korean = tmp[1].korean;
stu[pl].math = tmp[1].math;
stu[pl].science = tmp[1].science;
stu[pl].society = tmp[1].society;
stu[pl].sum = tmp[1].sum;
stu[pl].avr = tmp[1].avr;
}
}
}
puts(\"\\n\");
puts(\"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\");
puts(\" 이름 학번 수학 국어 영어 사회 과학 총점 평균\");
puts(\"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\");
for(i=0; i<num; i=i+1)
{
printf(\" %6s \", stu[i].name[10]);
printf(\"%10d\", stu[i].bunho);
printf(\"%7d\", stu[i].math);
printf(\"%7d\", stu[i].korean);
printf(\"%7d\", stu[i].english);
printf(\"%7d\", stu[i].society);
printf(\"%7d\", stu[i].science);
printf(\"%7d\", stu[i].science);
printf(\"%7d\\n\", stu[i].avr);
}
puts(\"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\");
}
-
정말 미치겠어요 형들 도와주세요 ㅜㅜ
코딩은 제대로 되는데 이름쪽에 문제가 있는지 출력만가면 에러뜨고 튕겨요
조공은 지연이에요 ㅜㅜ
조공은 지연(delayed)?
ㅋㅋ ㅜㅜ 돠주세요 ㅜㅜ
짤이 기분나빠서 안해줌
짤이 기분나빠서 안해줌
근데 진짜 와녁한 절차지향적으로 짰다
num변수 있는 곳좀 보게
c의 문자열에 대해 공부하고 와라
마지막에 printf(\" %6s \", stu[i].name[10]); 여기서 name[10]해서 틀린거였어여
걍 printf(\" %6s \", stu[i].name); 이렇게하면되는데 출력이왜이따위지...
char 배열은 저렇게 쓰지 않죠
입력도 문제니까 출력도 문제
뭐 시발 왜 출력이 이따위야 컴파일러 만든사람이 그렇게 쓴다는데
그리고 프로그램 짠 전체적인 구조도 정말정말임
만약에 저렇게 500줄 넘어가는 코딩하면 어휴 끔찍하다
짤 때문에 욕할래 씨발.
올ㅋ 포풍까임 ㅜㅜ