|
#include <iostream.h>
struct Test
{
int hakbun;
char name[13];
int kor;
int eng;
int tot;
};
Test aa[5];
void main(void)
{
int temp;
for(int i=0; i<5; i++)
{
cout << "학번=";
cin >> aa[i].hakbun;
cout << "이름=";
cin >> aa[i].name;
cout << "국어성적=";
cin >> aa[i].kor;
cout << "영어성적=";
cin >> aa[i].eng;
aa[i].tot = aa[i].kor + aa[i].eng;
}
cout << "\n 학번 이름 국어 영어 총합 \n";
for(int j=0; j<5; j++)
{
cout <<" "<<aa[j].hakbun<<" "<<aa[j].name<<" "<<aa[j].kor<<" "<<aa[j].eng<<" "<<aa[j].tot<< "\n";
}
for(int x=0 ; x<4 ;x++);
{
for(int y=(x+1) ; y<5 ; y++);
{
if(aa[x].tot<aa[y].tot)
{
temp=aa[x].tot;
aa[x].tot=aa[y].tot;
aa[y].tot=temp;
}
}
cout<<"등수별 학번과 이름 국어성적 영어성적 총점 출력\n";
cout <<" "<<aa[x].hakbun<<" "<<aa[x].name<<" "<<aa[x].kor<<" "<<aa[x].eng<<" "<<aa[x].tot<< "\n";
}
}
이렇게 프로그램을 짰는데염~
총점으로 소트를 시켜야 하거든여~
이 프로그램이 맞는지..
또 어서 cout를 해야 소트값이 나오는지 좀 알려주세여~
꼭 부탁드립니다.
|