-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeforces_Helpfulmaths.cpp
More file actions
79 lines (52 loc) · 1.19 KB
/
Codeforces_Helpfulmaths.cpp
File metadata and controls
79 lines (52 loc) · 1.19 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
70
71
72
73
74
75
76
77
#include<bits/stdc++.h>
using namespace std;
int main() {
string sumLine;
cin >> sumLine;
int countOne = 0, countTwo = 0, countThree = 0;
for(int i = 0; i < sumLine.size(); i++) {
if(sumLine[i] == '1') {
countOne++;
}
else if(sumLine[i] == '2') {
countTwo++;
}
else if(sumLine[i] == '3') {
countThree++;
}
else {
continue;
}
}
int countPrint = 0;
int countNmbrs = countOne + countTwo + countThree;
if(countOne > 0) {
while(countOne--) {
cout << "1";
countPrint++;
if(countPrint != countNmbrs) {
cout << "+";
}
}
}
if(countTwo > 0) {
while(countTwo--) {
cout << "2";
countPrint++;
if(countPrint != countNmbrs) {
cout << "+";
}
}
}
if(countThree > 0) {
while(countThree--) {
cout << "3";
countPrint++;
if(countPrint != countNmbrs) {
cout << "+";
}
}
}
cout << endl;
return 0;
}