Skip to content

Commit 25b1638

Browse files
committed
helpfulMaths
1 parent fa4931c commit 25b1638

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

Diff for: HelpfulMaths.cpp

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
char ch[150];
7+
int i, l, c1 = 0, c2 = 0, c3 = 0;
8+
gets(ch);
9+
l = strlen(ch);
10+
for (i = 0; i < l; i++)
11+
{
12+
if (ch[i] == '1')
13+
{
14+
c1++;
15+
}
16+
else if (ch[i] == '2')
17+
{
18+
c2++;
19+
}
20+
else if (ch[i] == '3')
21+
{
22+
c3++;
23+
}
24+
}
25+
for (i = 0; i < c1; i++)
26+
{
27+
cout << '1';
28+
if ((c2 == 0 && c3 == 0) && i == c1 - 1)
29+
{
30+
cout << endl;
31+
}
32+
else
33+
{
34+
cout << '+';
35+
}
36+
}
37+
for (i = 0; i < c2; i++)
38+
{
39+
cout << '2';
40+
if (i == c2 - 1 && c3 == 0)
41+
{
42+
cout << endl;
43+
}
44+
else
45+
{
46+
cout << '+';
47+
}
48+
}
49+
for (i = 0; i < c3; i++)
50+
{
51+
cout << '3';
52+
if (i == c3 - 1)
53+
{
54+
cout << endl;
55+
}
56+
else
57+
{
58+
cout << '+';
59+
}
60+
}
61+
return 0;
62+
}

0 commit comments

Comments
 (0)