Вы находитесь на странице: 1из 3

//Problem 1

//*****
//****
//***
//**
//5
//5 4
//5 4 3
//5 4 3 2
//5 4 3 2 1
int ss = 5;
int num = 5;
for(int i = 1; i <= 4; i++){
for(int x = 1; x <= ss; x++){
System.out.print("*");
}
System.out.println();
ss--;
}
for(int i = 1; i <= 5; i++){
num = 5;
for(int x = 1; x <= i; x++){
System.out.print(num + " ");
num--;
}
System.out.println();
ss--;
}
//Problem 1
//Problem 2
//* * * * *
//-* * * *
//--* * *
//---* *
//----*
//----1
//---2 2
//--3 3 3
//-4 4 4 4
//5 5 5 5 5
int s = 5;
for(int i = 1; i <= 5; i++){
for(int x = 1; x <= s; x++){
System.out.print("* ");
}
System.out.println();
for(int y = 1; y <= i; y++){
if(i < 5){
System.out.print(" ");
}
}
s--;
}
s = 4;
for(int i = 1; i <= 5; i++){
for(int y = 1; y <= s; y++){
if(i < 5){

System.out.print(" ");
}
}
for(int x = 1; x <= i; x++){
System.out.print(i + " ");
}
System.out.println();
s--;
}
//Problem 2
//Problem 3
//1 4 7 10 13
//1 3 9 27 81
//1 2 4 8 16
//0 1 4 9 16
for(int a = 1; a <= 13; a+=3){
System.out.print(a + " ");
}
System.out.println();
for(int b = 1; b <= 81; b*=3){
System.out.print(b + " ");
}
System.out.println();
for(int c = 1; c <= 16; c*=2){
System.out.print(c + " ");
}
System.out.println();
int sn = 0;
System.out.print(sn + " ");
for(int d = 0; d <= 7; d++){
if((d % 2) > 0){
System.out.print((sn += d) + " ");
}
}
//Problem 3
//Problem 4
//0 ------------- 1
//1 ------------- 2
//1 ------------- 4
//2 ------------- 8
//3 ------------- 16
//5 ------------- 32
//8 ------------- 64
//13 ------------- 128
//21 ------------- 256
//34 ------------- 512
int
int
int
int

n1 = 0;
n2 = 1;
oldn1;
tmp1 = 1;

System.out.println(n1 + "\t" + n2);


tmp1 = n1;

n1 += 1;
n2 *= 2;
for(int i = 1; i <= 9; i++){
System.out.println(n1 + "\t" + n2);
oldn1 = n1;
n1 += tmp1;
tmp1 = oldn1;
n2 *= 2;
}
//Problem 4

Вам также может понравиться