-
Notifications
You must be signed in to change notification settings - Fork 20
/
DSA02030 - LIỆT KÊ XÂU KÝ TỰ
62 lines (62 loc) · 2.23 KB
/
DSA02030 - LIỆT KÊ XÂU KÝ TỰ
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
56
57
58
59
60
61
62
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
char c;
int n, k;
cin >> c >> k;
n = c - 'A' + 1;
int a[k + 1];
for (int i = 1; i <= k; i++)
a[i] = 1;
while (1)
{
for (int i = 1; i <= k; i++)
cout << (char)('A' + a[i] - 1);
cout << endl;
int ok = 0;
for (int i = k; i >= 1; i--)
{
if (a[i] != n)
{
ok = 1;
a[i]++;
for (int j = i + 1; j <= k; j++)
a[j] = a[i];
break;
}
}
if (ok == 0)
break;
}
}
/* Do Xuan Huong
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@##################@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@#############################@@@@@@@@@@@@@@@@
@@@@@@@@@@@@&####################################@@@@@@@@@@@@
@@@@@@@@@@##########################################@@@@@@@@@
@@@@@@@@##############################################@@@@@@@
@@@@@@#################################################@@@@@@
@@@@@####################################################@@@@
@@@%#####################@@@@@@@@@@@######################@@@
@@@###################@@@@@@@@@@@@@@@@@####################@@
@@##################@@@@@@ @@@@@@##################@@
@@#################@@@@@ @@@@###################@
@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@
@ &@@@@ @@@@ .......@@
@@ @@@@@@ @@@@@@ .......@@
@@ @@@@@@@@@@@@@@@@@ .......@@@
@@@ @@@@@@@@@@@ ......@@@@
@@@@ ......@@@@@
@@@@@@ ......@@@@@@
@@@@@@@ .....@@@@@@@@
@@@@@@@@@ .....@@@@@@@@@@
@@@@@@@@@@@@ ....@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@ ....@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@% .@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*/