Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n=0;
- int[] mas = new int[50];
- string s,a1,a2=" ";
- s = Console.ReadLine();
- int p = s.Length;
- for (int i = 0; i < p; i++)
- {
- mas[i] = s[i]-48;
- }
- for(int i=0;i<p;i++)
- for(int j=i;j<p;j++)
- if(mas[i]>mas[j])
- {
- int u=mas[i];
- mas[i] = mas[j];
- mas[j] = u;
- }
- for (int i = 0; i < p; i++)
- if (mas[i] == 0)
- n++;
- if (p-n-1<1)
- {
- a1 = "-1";
- a2 = " -1";
- }
- else
- {
- if (n == 0)
- {
- a1 = Convert.ToString(mas[0]);
- for (int i = 1; i < p; i++)
- a2 = a2 + Convert.ToString(mas[i]);
- }
- else
- {
- a1 = Convert.ToString(mas[n]);
- mas[n] = 0;
- a2 = a2 + mas[n+1];
- for (int i = n; i > 0; i--)
- a2 = a2 + mas[i];
- for (int i = n+2; i < p; i++)
- a2 = a2 + mas[i];
- }
- }
- Console.WriteLine("{0}{1}",a1,a2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement