Advertisement
Guest User

Untitled

a guest
Feb 28th, 2018
140
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.  
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. string user = Console.ReadLine().ToUpper();
  11. StringBuilder result = new StringBuilder();
  12. int index = 0;
  13. while (true)
  14. {
  15. StringBuilder currentWord = new StringBuilder();
  16. StringBuilder currentRepeatCount = new StringBuilder();
  17. int repeatCount = 0;
  18. for (int i = index; i < user.Length; i++)
  19. {
  20. if (Char.IsDigit(user[i]))
  21. {
  22.  
  23. currentRepeatCount.Append(user[i]);
  24. int j;
  25. for (j = i+1; j < user.Length; j++)
  26. {
  27. if (Char.IsDigit(user[j]))
  28. {
  29. currentRepeatCount.Append(user[j]);
  30. }
  31. else
  32. break;
  33. }
  34. repeatCount = int.Parse(currentRepeatCount.ToString());
  35. index = j;
  36. break;
  37. }
  38. else
  39. currentWord.Append(user[i]);
  40. }
  41.  
  42. for (int i = 0; i < repeatCount; i++)
  43. {
  44. result.Append(currentWord.ToString());
  45. }
  46.  
  47.  
  48. if (index >= user.Length-1)
  49. {
  50. break;
  51. }
  52. }
  53. HashSet<char> uniqueChars = new HashSet<char>(result.ToString().ToArray());
  54. Console.WriteLine($"Unique symbols used: {uniqueChars.Count}");
  55. Console.WriteLine($"{result.ToString()}");
  56.  
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement