fork download
  1. using System;
  2. using System.Text;
  3.  
  4. namespace ConsoleApp4
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. string sosatHuj = Console.ReadLine();
  11. StringBuilder str = new StringBuilder(sosatHuj);
  12. int count = 0;
  13. int count2 = 0;
  14. for (int i = 0; i < str.Length - 1; i++)
  15. {
  16. if (str[i] == '(')
  17. {
  18.  
  19. if (count == 1)
  20. {
  21. str[i] = '[';
  22. }
  23. else if (count > 1)
  24. {
  25. str[i] = '{';
  26. }
  27. count++;
  28. }
  29. }
  30. for (int i = str.Length - 1; i > 0; i--)
  31. {
  32. if (str[i] == ')')
  33. {
  34.  
  35. if (count2 == 1)
  36. {
  37. str[i] = ']';
  38. }
  39. if (count2 > 1)
  40. {
  41. str[i] = '}';
  42. }
  43. count2++;
  44. }
  45. }
  46. Console.WriteLine(str);
  47. Console.ReadKey();
  48. }
  49. }
  50. }
Success #stdin #stdout 0.02s 14788KB
stdin
Standard input is empty
stdout