C言語なら俺に聞け! Part 115
■ このスレッドは過去ログ倉庫に格納されています
0095デフォルトの名無しさん
2005/09/28(水) 20:37:18#include <stdio.h>
#include <stdlib.h>
/* 比較用 */
int compare_int_ascending(const int *a, const int *b)
{
return *a - *b;
}
int main()
{
int array[] = { ... }; /* データ */
int count = sizeof(data)/sizeof(int);/* 要素数 */
int i;
/* ソート */
qsort(array, count, sizeof(int), (int (*)(const void*, const void*))compare_int_ascending);
for (i = 0; i < 10; i++) {
printf("%3d", array[i]);
}
printf("\n");
return 0;
}
■ このスレッドは過去ログ倉庫に格納されています