We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Warmup
- Staircase
- Discussions
Staircase
Staircase
Sort by
recency
|
5180 Discussions
|
Please Login in order to post a comment
My solution in C# builds the staircase row by row. For each row i (from 1 to n):
I print (n - i) spaces to align it to the right
Then I print i hash symbols (#)
This way the output grows step by step until the full staircase is printed.
Here is my solution in C (I know could be better) time complexity: O(n^2)
void staircase(int n) {
}
var sb=new StringBuilder();
Ussing operator overloading for fun, we all know it is not necessary.
for (int i = 1; i <= n; i++) { string bosluklar = new string(' ', n - i); string kareler = new string('#', i); Console.WriteLine(bosluklar + kareler); }