1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Arduino UNO 3でmax(最大)を求めて遊ぶ

Last updated at Posted at 2024-09-08

Arduino UNO 3でmax(最大)を求めて遊ぶ

目的
マクロを使い配列から最大値をサーチして求める
(正の数)(中学生以上からマイナスを習うから)(そもそも、ぱつと、見た瞬間、負のかずは、ないだろう)

いろいろ
アルゴリズムの教科書では、
ドラクエ1的に言ったらレベル99で最終章
いろいろ違うが、火山でふぅいやードラゴンが出るレベル

o_coq379.jpg



#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 max_a = 0;
  for (int i = 0; i < n; i++) {
    max_a = max(max_a, a[i]);
  }//for

  //結果の表示
  // print out the value you z:
  Serial.println(max_a);
  delay(1000);        // delay in between reads for stability

}//loop


1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?