Advertisement
Guest User

Untitled

a guest
Aug 13th, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace RageQuit_MoreEx
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. string text = Console.ReadLine().ToUpper();
  12.  
  13. string partText = "";
  14.  
  15. StringBuilder builder = new StringBuilder();
  16.  
  17. for (int i = 0; i < text.Length; i++)
  18. {
  19. if (!char.IsDigit(text[i]))
  20. {
  21. partText += text[i];
  22. }
  23.  
  24. else if (char.IsDigit(text[i]))
  25. {
  26. string number = text[i].ToString();
  27.  
  28. if (i + 1 < text.Length)
  29. {
  30. if (char.IsDigit(text[i + 1]))
  31. {
  32. number += text[i + 1];
  33. i += 1;
  34. }
  35. }
  36.  
  37. int counter = int.Parse(number);
  38.  
  39. for (int j = 0; j < counter; j++)
  40. {
  41. builder.Append(partText);
  42. }
  43.  
  44. partText = "";
  45. }
  46. }
  47.  
  48. StringBuilder textNoDigit = new StringBuilder();
  49.  
  50. for (int i = 0; i < text.Length; i++)
  51. {
  52. if (!char.IsDigit(text[i]))
  53. {
  54. textNoDigit.Append(text[i]);
  55. }
  56. }
  57.  
  58. for (int i = 0; i < textNoDigit.Length; i++)
  59. {
  60. for (int j = i + 1; j < textNoDigit.Length; j++)
  61. {
  62. if (textNoDigit[i] == textNoDigit[j])
  63. {
  64. textNoDigit.Remove(j, 1);
  65.  
  66. }
  67. }
  68. }
  69.  
  70. Console.WriteLine($"Unique symbols used: {textNoDigit.Length}");
  71. Console.WriteLine(builder);
  72.  
  73. }
  74. }
  75. }
  76.  
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement