Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Text;
- namespace _9._Rage_Quit
- {
- class Program
- {
- static void Main()
- {
- string [] words = new string [20000];
- short [] repeats = new short [20000];
- bool [] uniqueChars = new bool [130];
- StringBuilder input = new StringBuilder();
- short next=0;
- int index = 0;
- while (true)
- {
- short ch = (Int16)Console.Read();
- if (ch == 13) break;
- if (ch > 47 && ch < 58)
- {
- bool nextDigit = false;
- next = (Int16)Console.Read();
- if (next > 47 && next < 58) nextDigit = true;
- short rep = (nextDigit) ? (short)(((ch - 48) * 10) + next - 48) : (short)(ch - 48);
- if (rep > 0)
- {
- var word = input.ToString();
- words[index] = word;
- repeats[index] = rep;
- foreach (var letter in word)
- if (!uniqueChars[(int)letter]) uniqueChars[(int)letter] = true;
- }
- index++;
- input.Clear();
- if (next == 13) break;
- if (!nextDigit)
- {
- if (next > 96 && next < 123) next -= 32;
- input.Append((char)next);
- }
- }
- else
- {
- if (ch > 96 && ch < 123) ch -= 32;
- input.Append((char)ch);
- }
- }
- int count = 0;
- for (int i = 0; i < 130; i++) if (uniqueChars[i]) count++;
- Console.WriteLine($"Unique symbols used: {count}");
- StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
- sw.AutoFlush = true;
- Console.SetOut(System.IO.TextWriter.Null);
- for (int i=0; i< index; i++)
- {
- for (int j = 0; j < repeats[i]; j++) input.Append(words[i]);
- sw.Write(input);
- input.Clear();
- }
- // Console.SetOut(sw);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement