いろいろ注意
- 過去ログを見よ!!!
- Arduinoでの予定は、未定
- ピタゴラスの定理を使う(r x r)=(x x x)+(y x y)
プログラム
オンラインコンパイラpaiza
#include <iostream>
using namespace std;
int i_sqrt(int n){
//30
if( n > (32*32-1) ) return 32;
if( n > (31*31-1) ) return 31;
if( n > (30*30-1) ) return 30;
//20
if( n > (29*29-1) ) return 29;
if( n > (28*28-1) ) return 28;
if( n > (27*27-1) ) return 27;
if( n > (26*26-1) ) return 26;
if( n > (25*25-1) ) return 25;
if( n > (24*24-1) ) return 24;
if( n > (23*23-1) ) return 23;
if( n > (22*22-1) ) return 22;
if( n > (21*21-1) ) return 21;
if( n > (20*20-1) ) return 20;
//10
if( n > (19*19-1) ) return 19;
if( n > (18*18-1) ) return 18;
if( n > (17*17-1) ) return 17;
if( n > (16*16-1) ) return 16;
if( n > (15*15-1) ) return 15;
if( n > (14*14-1) ) return 14;
if( n > (13*13-1) ) return 13;
if( n > (12*12-1) ) return 12;
if( n > (11*11-1) ) return 11;
if( n > (10*10-1) ) return 10;
//1
if( n > (9*9-1) ) return 9;
if( n > (8*8-1) ) return 8;
if( n > (7*7-1) ) return 7;
if( n > (6*6-1) ) return 6;
if( n > (5*5-1) ) return 5;
if( n > (4*4-1) ) return 4;
if( n > (3*3-1) ) return 3;
if( n > (2*2-1) ) return 2;
if( n > (1*1-1) ) return 1;
return 0;
}
#define GURAFU(aa) for(int ii=0;ii<(aa+1);ii++){printf("*");}
int main(void){
// Your code here!
for(int y =0;y<(30+1);y++){
//(r*r) = (y*y) + (x*x)
//(30*30) = (y*y) + (x*x)
//(30*30) - (y*y) = (x*x)
//x = SQRT(x*x)
int x,xx,f;
xx = (30*30) - (y*y);
x = i_sqrt(xx);
//printf("%d=SQ(%d)\n",x,xx);
GURAFU(x);printf("\n");
}
}
*******************************
******************************
******************************
******************************
******************************
******************************
******************************
******************************
*****************************
*****************************
*****************************
****************************
****************************
****************************
***************************
**************************
**************************
*************************
*************************
************************
***********************
**********************
*********************
********************
*******************
*****************
***************
**************
***********
********
*