-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSA01007.cpp
More file actions
54 lines (52 loc) · 689 Bytes
/
Copy pathDSA01007.cpp
File metadata and controls
54 lines (52 loc) · 689 Bytes
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
#include<bits/stdc++.h>
using namespace std;
bool check(int a[], int n)
{
int l = 1;
int k = n;
while(l<=k)
{
if(a[l] != a[k]) return 0;
l++;
k--;
}
return 1;
}
int main()
{
int t;
cin >> t;
while(t--)
{
int n;
cin >> n;
char a[n+5];
for(int i = 1; i<=n; i++)
{
a[i] = 'A';
}
while(1)
{
for(int i = 1; i<=n; i++)
{
cout << a[i];
}
cout <<' ';
int l = n;
while(a[l] == 'B' && l)
{
a[l] = 'A';
l--;
}
if(l==0)
{
break;
}
else
{
a[l] = 'B';
}
}
cout << endl;
}
}