View Code of Problem 2592

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
    int n;
    char ch;
    bool flag=0;
    while((cin>>ch),(ch!='@')){
            if(flag) printf("\n");
            flag=1;
            cin>>n;
            if(n==1) printf("%c\n",ch);
            else{
            int b=n-2;
            int c=1;
            for(int i=1;i<=n-1;i++) printf(" ");
            printf("%c\n",ch);
            for(int i=2;i<=n-1;i++){
                for(int j=1;j<=b;j++) printf(" ");
                printf("%c",ch);
                for(int j=1;j<=c;j++) printf(" ");
                printf("%c\n",ch);
                b--;
                c+=2;
            }
            for(int k=1;k<=2*n-1;k++){
                printf("%c",ch);
                if(k==2*n-1) printf("\n");    
            } 
        }
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 2592