-
Notifications
You must be signed in to change notification settings - Fork 342
/
HelpfulMaths.cpp
62 lines (61 loc) · 1016 Bytes
/
HelpfulMaths.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
57
58
59
60
61
62
#include <bits/stdc++.h>
using namespace std;
int main()
{
char ch[150];
int i, l, c1 = 0, c2 = 0, c3 = 0;
gets(ch);
l = strlen(ch);
for (i = 0; i < l; i++)
{
if (ch[i] == '1')
{
c1++;
}
else if (ch[i] == '2')
{
c2++;
}
else if (ch[i] == '3')
{
c3++;
}
}
for (i = 0; i < c1; i++)
{
cout << '1';
if ((c2 == 0 && c3 == 0) && i == c1 - 1)
{
cout << endl;
}
else
{
cout << '+';
}
}
for (i = 0; i < c2; i++)
{
cout << '2';
if (i == c2 - 1 && c3 == 0)
{
cout << endl;
}
else
{
cout << '+';
}
}
for (i = 0; i < c3; i++)
{
cout << '3';
if (i == c3 - 1)
{
cout << endl;
}
else
{
cout << '+';
}
}
return 0;
}