-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelpful_Maths.cpp
73 lines (63 loc) · 1.38 KB
/
Helpful_Maths.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
63
64
65
66
67
68
69
70
71
72
73
#include <bits/stdc++.h>
using namespace std;
int main(){
string s; int i=0;
cin>>s;
int n = s.length();
if (n%2==0)
{
int a[n/2];
for (int m=0; m < n/2; m++)
{
a[m] = int(s[2*m])-48 ;
}
/*for (int l = 0; l < n/2; l++)
{
cout<<a[l]<<"a["<<l<<"]i"<<endl;
}
*/
sort(a,a+n/2+1);
/*for (int k = 0; k < n/2; k++)
{
cout<<a[k]<<"a["<<k<<"]f"<<endl;
}
*/
for (int t = 0; t < n/2; t++)
{
if (t==n/2-1)
{
cout<<a[t];
break;
}
cout<<a[t]<<"+";
}
}
else
{
int a[n/2+1];
for (int m=0; m < n/2+1; m++)
{
a[m] = int(s[2*m])-48 ;
}
/*for (int l = 0; l < n/2+1; l++)
{
cout<<a[l]<<"a["<<l<<"]i"<<endl;
}
*/
sort(a,a+n/2+1);
/*for (int k = 0; k < n/2+1; k++)
{
cout<<a[k]<<"a["<<k<<"i]f"<<endl;
}
*/
for (int i = 0; i < n/2+1; i++)
{
if (i==n/2)
{
cout<<a[i];
break;
}
cout<<a[i]<<"+";
}
}
}