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?

UNO)二個のサイコロの目の合計の期待値を求める

Last updated at Posted at 2024-09-14

目的
合計、平均の応用のアルゴリズム

いろいろ
ドラクエ1だとレベル55+++ぐらい、ぼほ真ん中
元ネタは、放送大学のアルゴリズム(いつの?)、単位は、当然単位取得済み
おまけ(あんない)として動画圧縮(フーリエ級数)や暗号(素数)が例として出ていた。
暗号にかんしては、キーがないと解けないのが暗号だからムズイ
ハードゲット

型番 110060131

Grove Starter Kit for BeagleBone Green

o_coq397.jpg

結果

o_coq396.jpg

プログラム



//niko_no_me_kitaiti_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


//メインループ
// the loop routine runs over and over again forever:
void loop() {

  //総和を求める
  int z = 0; int a;
  for (int i = 1; i <= 6; i++) {
    for (int j = 1; j <= 6; j++) {
      z = z + i + j;
    }//for j
  }//for i

  //総和で割って平均を求める
  a = z / (6 * 6);

  //結果の表示
  // print out the value you a:
  Serial.println(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?