-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx_pair_x^2.cpp
55 lines (52 loc) · 1.02 KB
/
x_pair_x^2.cpp
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
48
49
50
51
52
53
54
55
#include<iostream>
using namespace std;
bool check(int x,int*arr,int sizee)
{
for(int i=0;i<sizee;i++)
{
if(arr[i]==x*x)
{
arr[i]=-1;for(int i=0;i<x;i++)
{
cin>>arr[i];
}
return true;
}
}
return false;
}
int main()
{
int t;cin>>t;
while(t--)
{
int arr[50];
int x;
cout<<"enter size of array";
cin>>x;
for(int i=0;i<x;i++)
{
cin>>arr[i];
}
for(int i=0;i<x;i++)
{
if(arr[i]==(-1)) continue;
else
{
if(check(arr[i],arr,x))
{
for(int j=0;j<x;j++)
{
cout<<arr[j];
}
cout<<endl;
arr[i]=-1;
cout<<i<<endl;;
}
else{cout<<"no";break;}
}
if(i+1==x)
cout<<"perfact";
}
}
}