You are viewing a single comment's thread. Return to all comments →
lost few braincells while doing it, here is cpp #include using namespace std;
int main(){
int n; cin >> n; int a=n; int b=1; for(int i=1;i<=2*n-1;i++){ if(i<=n){ for(int j=1;j<=i;j++){ if(j==n){break;} cout << n+1-j; }for(int j=1;j<=2*n-1-2*i;j++){ cout << n+1-i; }for(int j=1;j<=i;j++){ cout << a++; }a=n-(i); }else{ for(int j=2*n-1;j>=i;j--){ cout << j-(n-1); }for(int j=1;j<=2*i-2*n-1;j++){ cout <<i-(n-1); }for(int j=2*n-1;j>=i;j--){ cout << ++b; }b=1+(i-n); }cout << endl; }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Printing Pattern Using Loops
You are viewing a single comment's thread. Return to all comments →
lost few braincells while doing it, here is cpp #include using namespace std;
int main(){
}