- 1
* ** **** ******** **************** I can't solve this problem! the asterisk should be doubled on each line than previous
the asterisk value should be doubled on each line! please help me out.
6 odpowiedzi
+ 3
Without using the Math class:
int x = 1;
for ( int i = 0; i < 5; i++ ) {
for ( int j = 0; j < x; j++ ) {
Console.Write( "*" );
}
x *= 2;
Console.WriteLine();
}
+ 2
int n = 4;
for (int i = 1; i <= Math.Pow(2.0, n); i*=2) {
for (int j = 1; j <= i; j++) {
Console.Write("*");
}
Console.WriteLine();
}
+ 2
Or, for less code:
int x = 1;
for ( int i = 0; i < 5; i++ ) {
Console.Write( new string( '*', x ) + "\n" );
x *= 2;
}
+ 1
can you write manually without inbuilt operations like power
+ 1
thank you liam! you're great
0
for ( int x = 1; x < 17; x *= 2 )
Console.WriteLine( new string ( "*", x ) );