-
Notifications
You must be signed in to change notification settings - Fork 0
/
123.cpp
56 lines (54 loc) · 1.16 KB
/
123.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
56
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int a[4];
int main(void)
{
int c = 0;
//freopen("data.txt","r",stdin);
while (~scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]))
{
if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0)
{
break;
}
sort(a, a + 4);
if (c != 0)
{
printf("\n");
}
c++;
int now = a[0];
int i = 0;
while (a[i] == 0)
{
now = a[++i];
}
bool flag = true;
do
{
if (a[0] == 0)
{
//printf("\n");
continue;
}
if (flag)
{
printf("%d%d%d%d", a[0], a[1], a[2], a[3]);
flag = false;
}
else if (a[0] == now)
{
printf(" %d%d%d%d", a[0], a[1], a[2], a[3]);
}
else
{
printf("\n%d%d%d%d", a[0], a[1], a[2], a[3]);
}
now = a[0];
} while (next_permutation(a, a + 4));
printf("\n");
}
return 0;
}