#include #include #define N 100 main() { int i, n; int top; int table[N+1]; table[1]=37; /* 「あらかじめ」格納する */ table[2]=56; table[3]=98; table[4]=27; table[5]=50; table[6]=84; table[7]=78; table[8]=24; table[9]=94; table[10]=89; n=10; /* データの表示 */ printf("以下のデータから 最高点の学生を探します。\n"); for( i=1 ; i<=n ; i=i+1 ){ printf("%2d:%5d\n",i,table[i]); } /*ここからアルゴリズムの本体 */ top = table[1]; for( i=2; i<=n; i=i+1) if(table[i]>top) top = table[i]; /* ここまでアルゴリズムの本体 */ /* 結果の表示 */ printf("最高点は %d 点です。\n",top); exit(0); } 【実行結果例】 okada@hazel[3]_% gcc -o practice6-2 practice6-2.c -lm okada@hazel[4]_% practice6-2 以下のデータから 最高点の学生を探します。 1: 37 2: 56 3: 98 4: 27 5: 50 6: 84 7: 78 8: 24 9: 94 10: 89 最高点は 98 点です。 okada@hazel[5]_%