Struct 함수/정렬
세라
2023.04.01
#include stdio.h
#include string.h
struct student{
char name[20];
int num;
};
int main()
{
student s1[10]={{김소라,30},
{김소월,89},{김한라,100},{김승호,96},
{유정현,67},{이정석,30},{오하라,15},
{김조한,90},{강태풍,59},{변태환,85}};
int i;
for(i=0; i10; i++){
printf(%7s%5d\n, s1[i].name, s1[i].num);
}
return 0;
}
void sort(int s1[], int n)
{
int i,j,min,temp;
for(i=0; i10; i++)
{
min = i;
for(j=i+1; j11; j++)
if(s1[i] s1[min])
min = j;
}
}
이렇게 함수를 지정하고 햇는데요..
ex) 김조한 90 유정현 67
유정현 67 - 오름차순정렬 변태환 85
변태환 85 김조한 90
.............
binsearch 이걸 이용해서 ex) 67점 - 유정현 없으면 없다고표시
이런식으로 나타낼려고하거든요..
소스좀 올바르게 고쳐주세요.