目的
おりる順で並び替えをする
いろいろ
直線探索で大きいのを見つけていく
ドラクエ1的には、ちょつと違うけどえんでんぐが流れるレベル
(クイックソートとかもあるけど)
#include <Arduino.h>
//max_wo_sagasu_UNO_1
//初期化
// the setup routine runs once when you press reset:
void setup() {
//シリアルポートの初期化
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}//setup
//配列の個数
#define n 20
//メインループ
// the loop routine runs over and over again forever:
void loop() {
//配列の定義
int a[n] = {
67, 36, 69, 73, 51, 55, 40, 43, 29, 35,
70, 49, 34, 01, 41, 41, 53, 67, 34, 03
};
int t = 0; //テンポラリー(一時領域)
for (int j = 0; j < (n - 1); j++) { //大きい順をひとつづつ決める
for (int i = (j + 1); i < n; i++) { //直線探索
if (a[i] > a[j]) { //大きいときは、入れ替える
t = a[i];
a[i] = a[j];
a[j] = t;
}//endif
}//for i
}//for j
//結果の表示
// print out the value you a[]:
for (int i = 0; i < n; i++) {
Serial.print(a[i]);
Serial.print(',');
}//for
Serial.println();
delay(1000); // delay in between reads for stability
}//loop