-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTheGridFillProblem.cpp
More file actions
47 lines (47 loc) · 1.01 KB
/
TheGridFillProblem.cpp
File metadata and controls
47 lines (47 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin>>T;
int arr[T];
for (int i=0;i<T;i++)
{
cin>>arr[i];
}
for(int j=0;j<T;j++)
{
int arr2[arr[j]][arr[j]];
if(arr[j]>=2 && arr[j]%2==0)
{
for(int k=0;k<arr[j];k++)
{
for(int l=0;l<arr[j];l++)
{
arr2[k][l] = -1;
cout<<arr2[k][l]<<" ";
}
cout<<endl;
}
}
if(arr[j]>=2 && arr[j]%2!=0)
{
for(int m=0;m<arr[j];m++)
{
for (int n=0;n<arr[j];n++)
{
if(n==m)
{
arr2[m][n]=-1;
}
if(n!=m)
{
arr2[m][n]=1;
}
cout<<arr2[m][n]<<" ";
}
cout<<endl;
}
}
}
}