shape numbers reverse triangle
Mon Oct 30 2023 17:24:58 GMT+0000 (Coordinated Universal Time)
Saved by
@yolobotoffender
/* Write a program in C++ to display such a pattern for n number of rows using numbers. There will be odd numbers in each row. The first and last number of each row will be 1 and the middle column will be the row number. N numbers of columns will appear in the 1st row.
Sample Output:
Input number of rows: 7
1234567654321
12345654321
123454321
1234321
12321
121
1 */
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int num;
cout<<"enter the number of rows:"<<endl;
cin>>num;
for(int r=1;r<=num;r++){
for(int s=0;s<=r-1;s++){
cout<<' ';
}
for(int c1=1;c1<num;c1++){
cout<<c1;
}
for(int c2=num;c2>=1;c2--){
cout<<c2;
}
cout<<endl;
num=num-1;
}
return 0;
}
content_copyCOPY
Comments