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?

ピタゴラスの定理で遊ぶ。(斜辺を求めよ)(手計算で確認できる程度の整数)

Last updated at Posted at 2025-02-23

参照

o_coq826.jpg

注意、いろいろ

  • 過去ログを見よ!!!
  • M5NanoC6での予定は、未定
  • 平方根のプログラムをせつかく作ったので

目的

直角三角形の斜辺を求める

ピタゴラス数の一番小さい
a = 3
b = 4
c = □

プログラム

オンラインコンパイラ




#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    //9x9=81
    //10x10=100
    //11x11=121
    
    int s;
    int y; //二乗
    int i; //カウンター
    
    int a;
    int b;
    
    printf("START\n\n");
    
    a = 3;
    b = 4;
    
    printf("a = %d\n\n",a);
    printf("b = %d\n\n",b);
    
    s = (a * a)+(b * b);
    
    printf("INPUT %d\n",s);
    printf("...\n");
    
    i = -1;
    y = 0;
    while(y <= s){ //超えた場合に抜ける
        i = i + 1;
        y = i * i;
        printf("%d=SQ(%d)\n",i,y);
    }
    i = i - 1;
    
    printf("...\n");
    printf("Answer %d=SQ(%d)\n",i,s);
}




START

a = 3

b = 4

INPUT 25
...
0=SQ(0)
1=SQ(1)
2=SQ(4)
3=SQ(9)
4=SQ(16)
5=SQ(25)
6=SQ(36)
...
Answer 5=SQ(25)


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?