C言語なら俺に聞け! Part 119
■ このスレッドは過去ログ倉庫に格納されています
0084デフォルトの名無しさん
2005/12/22(木) 00:02:32struct StudentA{
int id;
int english;
int math;
int chem;
};
struct StudentB{
int id;
int subject[3];
};
int compA(const void *a,const void *b){
return ((struct StudentA *)a)->english - ((struct Student A *)b)->english;
}
void main(){
int key;
struct StudentA seitoA[5];
struct StudentB seitoB[5];
qsort(seitoA,5,sizeof(struct StudentA),compA);
key=2; /* 例えば */
qsort(seitoB,5,sizeof(struct StudentB),compB);
}
englishの値によってseitoAを並び替える比較関数compAは作れるんですが、
subject[key]の値によってseitoBを並び替える比較関数がうまく作れません。
教えていただけないでしょうか。
■ このスレッドは過去ログ倉庫に格納されています