Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7.  
  8. namespace ConsoleApplication1
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. int n=0;
  15. int[] mas = new int[50];
  16. string s,a1,a2=" ";
  17. s = Console.ReadLine();
  18. int p = s.Length;
  19. for (int i = 0; i < p; i++)
  20. {
  21. mas[i] = s[i]-48;
  22. }
  23. for(int i=0;i<p;i++)
  24. for(int j=i;j<p;j++)
  25. if(mas[i]>mas[j])
  26. {
  27. int u=mas[i];
  28. mas[i] = mas[j];
  29. mas[j] = u;
  30. }
  31. for (int i = 0; i < p; i++)
  32. if (mas[i] == 0)
  33. n++;
  34. if (p-n-1<1)
  35. {
  36. a1 = "-1";
  37. a2 = " -1";
  38. }
  39. else
  40. {
  41. if (n == 0)
  42. {
  43. a1 = Convert.ToString(mas[0]);
  44. for (int i = 1; i < p; i++)
  45. a2 = a2 + Convert.ToString(mas[i]);
  46. }
  47. else
  48. {
  49. a1 = Convert.ToString(mas[n]);
  50. mas[n] = 0;
  51. a2 = a2 + mas[n+1];
  52. for (int i = n; i > 0; i--)
  53. a2 = a2 + mas[i];
  54. for (int i = n+2; i < p; i++)
  55. a2 = a2 + mas[i];
  56.  
  57. }
  58. }
  59. Console.WriteLine("{0}{1}",a1,a2);
  60.  
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement