Problem: Contest Page | CodeChef
DIFFICULTY:
EASY.
PROBLEM:
The chef is trying to decode 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;
int main()
{
//code
ofstream mpp;
mpp.open("output.txt");
int t;
cin>>t;
while(t--){
int n,x=1;
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
int n=x++;
std::vector<int> v;
while(n>0){
v.push_back(n%2);
n=n/2;
}
for(int i=0;i<v.size();i++)cout<<v[i];
cout<<" ";
}
cout<<endl;
}
}
}