/* The Output should look like this
5 1
4 2
3
4 2
5 1
or
7 1
6 2
5 3
4
5 3
6 2
7 1
*/
but so far I can only get a V shape.
int main(int argc, char** argv) {
int n;
int x;
cout<<"Enter an integer between 1-50.\n";
cin>>n;
if(n%2==1){ //loop for odd integers.
x = n;
for(int i = 1; i <= n; i++){
cout<<setw(i)<<x<<setw(2*x)<<i<<endl;
x--;
}
}else{ //branch for even integers.
}
return 0;
}
/*Right now my output looks like this:
5 1
4 2
3 3
2 4
1 5
*/
I'm having a hard time figuring out how to get the lines to converge at the middle number then diverge out.
Nope that basically does the same thing I did with the formatting.
I'm having a hard time figuring out how to get the lines to converge at the middle number then diverge out.