Advertisement
Vladimir76

Untitled

Jan 1st, 2017
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.05 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.  
  7. namespace Rage_Quit
  8. {
  9.     class Program
  10.     {
  11.         static List<char> arr = new List<char>();
  12.         static List<char> arrCharNumber = new List<char>();
  13.         static List<char> sbLetter = new List<char>();
  14.         static StringBuilder sbDigits = new StringBuilder();
  15.  
  16.         static void AddLetter(int valueDigit)
  17.         {
  18.             for (int j = 0; j < valueDigit; j++)
  19.             {
  20.                 for (int i = 0; i < sbLetter.Count; i++)
  21.                 {
  22.                     arr.Add(sbLetter[i]);
  23.                 }
  24.             }
  25.         }
  26.         static void PrintSymbols()
  27.         {
  28.             foreach (var val in arr)
  29.             {
  30.                 Console.Write("{0}", val);
  31.             }
  32.             Console.WriteLine();
  33.         }
  34.  
  35.         static void Main()
  36.         {
  37.             string str = Console.ReadLine().ToUpper();
  38.             int digit;
  39.  
  40.             for (int i = 0; i < str.Length; i++)
  41.             {
  42.                 if (Char.IsLetter(str[i]) || !Char.IsLetterOrDigit(str[i]))
  43.                 {
  44.                     sbLetter.Add(str[i]);
  45.                 }
  46.                 else
  47.                 {
  48.                     sbDigits.Append(str[i]);
  49.                     if (i < str.Length - 1 && !Char.IsDigit(str[i + 1]) || (i == str.Length - 1))
  50.                     {
  51.                         digit = Convert.ToInt32(sbDigits.ToString());
  52.                         AddLetter(digit);
  53.                         sbLetter.Clear();
  54.                         sbDigits.Clear();
  55.                     }
  56.                 }
  57.                 if (arrCharNumber.Contains(str[i]) || Char.IsDigit(str[i]))
  58.                 {
  59.                     continue;
  60.                 }
  61.                 else
  62.                 {
  63.                     arrCharNumber.Add(str[i]);
  64.                 }
  65.             }
  66.             Console.WriteLine("Unique symbols used: {0}", arrCharNumber.Count);
  67.             PrintSymbols();
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement