I want to make a triangle with this pattern:
1
11
111
then repeat the last row as much as how many rows in it:
1
11
111
111
111
111
I already made code for the triangle pattern, but I'm stuck on looping the last row. Here's my code:
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
int rows;
cin>>rows;
for(int i=1;i<=rows;i++){
for (int j = 1; j <= i; j++)
{
cout<<"1";
}
cout<<endl;
}
return 0;
}
thanks