Statement
Sequential statements
Branch statement
Loop statement
1. Initial Conditions
2. Cyclic Conditions
3. Loop body
4. Status Change
For (initial condition; cyclic condition; state change)
{
Loop body;
}
Exhaustion
Iteration Method
1,
Console. Write ("Enter the number :");
Int n = convert. toint32 (console. Readline ());
For (INT I = 1; I <= N; I ++)
{
For (int A = 1; A <= N-I; A ++)
{
Console. Write ("");
}
For (INT B = 1; B <= (2 * I-1); B ++)
{
Console. Write ("☆ ");
}
Console. Write ("\ n ");
}
For (Int J = 1; j <n; j ++)
{
For (INT c = 1; C <= J; C ++)
{
Console. Write ("");
}
For (INT d = 1; D <= 2 * (N-j)-1; D ++)
{
Console. Write ("☆ ");
}
Console. Write ("\ n ");
}
2. The height of a basketball player drops from 10 high to 3/4 of the previous height.
Console. Write ("Enter times :");
Int n = convert. toint32 (console. Readline ());
Double H = 10;
For (INT I = 1; I <= N; I ++)
{
H * = 3/4;
Console. writeline ("bounce height" + H );
}
3. A young rabbit grows into a rabbit after one month (each rabbit defaults to a male and a mother). After another month, it grows into a rabbit and gives birth to a rabbit, and so on. How many rabbits are there in two years?
Int A = 1, B = 0, c = 0, m = 0, n = 0;
For (INT I = 1; I <= 24; I ++)
{
If (I = 1)
{
M = 1;
N = 0;
C = 0;
}
Else
{
M = B + C;
N =;
C = m;
A = m;
B = N;
}
Console. writeline (I );
Console. writeline ("Rabbit:" + M );
Console. writeline ("Rabbit:" + n );
Console. writeline ("Rabbit:" + C );
Console. writeline ("Total:" + (m + n + C ));
}