ITGUY12 - Editorial

Problem: CodeChef: Practical coding for everyone

DIFFICULTY:

EASY.

PROBLEM:

The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.

Program:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t–){
int n;
cin>>n;
for(int i=n;i>=-n;i–)
{ for(int j=1;j<=abs(i);j++)cout<<" “;
for(int j=abs(i);j<=n;j++)cout<<j;
cout<<”\n";
}
}
return 0;
}