-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalex65af2789.cs
76 lines (72 loc) · 2.01 KB
/
alex65af2789.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _2789___Sum_Order
{
class Program
{
static void Main(string[] args)
{
string cadena;
int uno = 0;
int dos = 0;
int tres = 0;
cadena = Console.ReadLine();
for (int i = 0; i < cadena.Length; i++)
{
if (cadena[i] == '1')
{
uno++;
}
else if (cadena[i] == '2')
{
dos++;
}
else if (cadena[i] == '3')
{
tres++;
}
}
if (uno != 0)
{
for (int i = 0; i < uno; i++)
{
Console.Write('1');
if (i!=uno-1)
Console.Write('+');
if ( i == uno-1)
{
if (dos != 0 || tres != 0)
Console.Write('+');
}
}
}
if (dos != 0)
{
for (int i = 0; i < dos; i++)
{
Console.Write('2');
if (i != dos - 1)
Console.Write('+');
if (i==dos-1)
{
if (tres != 0)
Console.Write('+');
}
}
}
if (tres != 0)
{
for (int i = 0; i < tres; i++)
{
Console.Write('3');
if (i != tres - 1)
Console.Write('+');
}
}
Console.ReadKey();
}
}
}