for loop doesn't work. please help!

I am trying to make a Isosceles triangle by outputting a single character on a single line on the command line. I don't know why it only prints out the half of the Isosceles triangle. It ignores the part of the for loop of rows of decreasing length.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <cctype>
using namespace std;


int main() {
  int m;
    cout << "Enter a width in between 1 - 70: ";
    cin >> m;
    cin.ignore(1000, 10);
    while (m < 1 || m > 70) {
      cout << "Please enter a correct width again!" << endl;
      return main();
    }


    int n = 1;
    while(true)
    {
        for (int i= 0 ; i < m; ++i)
        {
            for (int j = 0; j < n; ++j) 
            {
               for ( int k=0 ; k <i ;++k)
                    {
                    cout << '*' ;
                    }
            }
         cout << endl;
        }


        for (int i = m; i < m; i--){
            for( int j = 0; j <n ; ++j){
                for (int k=m ; k <i ; k--){
                cout << '@';}
            }
        cout <<endl;
        }
    }
}
Last edited on
Topic archived. No new replies allowed.