-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlietkevadem.c
More file actions
69 lines (69 loc) · 1.14 KB
/
lietkevadem.c
File metadata and controls
69 lines (69 loc) · 1.14 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdio.h>
typedef struct NO
{
int so, dem;
} N;
int num_up(int n)
{
int c = n % 10, b;
n = n / 10;
while (n > 0)
{
b = n % 10;
if (b > c)
return 0;
c = b;
n /= 10;
}
return 1;
}
int find(N a[], int n, int x)
{
for (int i = 0; i < n; i++)
{
if (a[i].so == x)
return i;
}
return -1;
}
void arange(N b[], int i)
{
for (int j = 0; j < i; j++)
{
for (int m = j + 1; m < i; m++)
if (b[j].dem < b[m].dem)
{
N a = b[j];
b[j] = b[m];
b[m] = a;
}
}
}
int main()
{
N a[100001];
int n = 0;
int x;
while (scanf("%d", &x) != -1)
{
if (num_up(x))
{
int idx = find(a, n, x);
if (idx != -1)
{
a[idx].dem++;
}
else
{
a[n].so = x;
a[n].dem = 1;
n++;
}
}
}
arange(a, n);
for (int i = 0; i < n; i++)
{
printf("%d %d\n", a[i].so, a[i].dem);
}
}