수다님 죄송합니다... 이것좀 한번만 더 봐주세요~!!
화이티
오와~ 이렇게 했는데 되었어요!!질문 제목 : 배열 정렬 문제....데이터 파일
20074242 62 75 73
20081234 99 60 87
20074243 55 83 67
20067044 100 100 70
질문 내용 :
#includestdio.h
#define size 100;
typedef struct {
int temp[4][100];
} List;
int main()
{
List list;
FILE *fp;
int total[100];
double avg[100];
int count=0,i,j;
double key;
fp=fopen(data.txt,r);
if(fp==NULL)
{
printf(파일이 열리지 않았습니다.\n);
return 0;
}
while(!feof(fp))
{
fscanf(fp,%d%d%d%d,&list.temp[0][count], &list.temp[1][count], &list.temp[2][count], &list.temp[3][count]);
count++;
}
printf(Before Sorting!!\n);
printf(학번\t 국어 영어 수학 총점\t평균\n);
for(i=0; icount; i++)
{
total[i]=list.temp[1][i]+list.temp[2][i]+list.temp[3][i];
avg[i]=total[i]/3.00;
}
for(i=0; icount; i++)
{
printf(%d\t%d\t%d\t%d\t,list.temp[0][i],list.temp[1][i],list.temp[2][i],list.temp[3][i]);
printf(%d\t%2.2f\n,total[i],avg[i]);
}
printf(\n\nAfter Sorting!!\n);
printf(학번\t 국어 영어 수학 총점\t평균\n);
for(i=0; icount; i++)
{
key = avg[i] ;
for(j=i-1; j=0 && avg[j]key; j--)
avg[j+1] = avg[j];
avg[j+1] = key;
}
for(i=0; icount; i++)
{
printf(%d\t%d\t%d\t%d\t,list.temp[0][i],list.temp[1][i],list.temp[2][i],list.temp[3][i]);
printf(%d\t%2.2f\n,total[i],avg[i]);
}
fclose(fp);
return 0;
}
-
장난감
list[j+1] = key; 이부분이 자꾸 에러가 나네요 ㅜㅜ
-
가리매
평균 정렬해서 학번,점수,평균전부다 정렬된채로 출력하려구요~ㅜㅜ
-
여신
아 ㅜㅜ 처음에 그거 나오는 것만 확인하려고 넣은거라서요....
정렬한 후에 배열 출력하는 거 문장으로 바꿨어요~ -
아라
for(i=0; icount; i++)
{
int key = avg[i] ;
for(j=i-1; j=0 && avg[j]key; j--)
avg[j+1] = avg[j];
list[j+1] = key;
}
// 이건 왜 갈아 치우셨쎄요?
for(i=0; icount; i++)
{
printf(\%d\\n\ -
VE
흑 ㅜㅜ
-
하예
켁~
-
봄여울
수다님 ㅜㅜ
제 글에 답글 남겨주셔서 감사해요`~
그런데 어떻게 이걸 소스에 이용해야 할지 모르겠어요 ㅠㅠㅠㅠ -
보단
아..죄죄...송해요 ㅋㅋㅋㅋㅋㅋㅋㅋ
-
겨루
for(i=0; icount; i++)
{
int key = avg[i] ;
for(j=i-1; j=0 && avg[j]key; j--)
avg[j+1] = avg[j];
list[j+1] = key;
} -
내담
켁... 얼마나 대단한 소스길래 복사도 안되게... -_ㅡ;;