Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Diagnostics;
- using System.Threading;
- namespace mainSolution
- {
- public class MyException : Exception
- {
- public MyException(string messege) : base(message: messege + "\n\n\n Exception founded by Decibit\n\n\n") { }
- public MyException() : base()
- {
- }
- public void Messsage()
- {
- Console.WriteLine("\n\n\n\n\n\n Invalid number, please enter a number from 1 to 12 \n\n\n\n\n\n");
- }
- }
- class Input
- {
- private static IEnumerator<string> getin()
- {
- while (true)
- foreach (string s in Console.ReadLine().Split().Where(x => x.Length > 0))
- yield return s;
- }
- private IEnumerator<string> inp = getin();
- public string GetString() { inp.MoveNext(); return inp.Current; }
- public int GetInt() { return int.Parse(GetString()); }
- public long GetLong() { return long.Parse(GetString()); }
- public double GetDouble() { return double.Parse(GetString()); }
- }
- public class Pair<T, K>
- {
- public T First { get; set; }
- public K Second { get; set; }
- }
- static class Program
- {
- static public Input cin = new Input();
- static bool cmp(Pair<int, int> a, Pair<int, int> b)
- {
- if (a.First > b.First)
- return true;
- else
- return false;
- }
- static StringBuilder NextPermutatuin(StringBuilder s, int shift)
- {
- shift = 'о' - 'а' - shift;
- StringBuilder res = new StringBuilder();
- for (int i = 0; i < s.Length; i++)
- {
- if (s[i] == ' ')
- {
- res.Append(' ');
- continue;
- }
- res.Append(Convert.ToChar(s[i] + shift));
- }
- return res;
- }
- static void Main(string[] args)
- {
- List<Pair<int, int>> cnt = new List<Pair<int, int>>(101);
- for (int i = 0; i < 100; i++)
- {
- cnt.Add(new Pair<int, int> ());
- cnt[i] = new Pair<int, int>();
- cnt[i].Second = i;
- }
- //int sh = 2;
- string t = Console.ReadLine();
- StringBuilder s = new StringBuilder();
- for (int i = 0; i < t.Length; ++i)
- {
- s[i] = t[i];
- }
- /*
- for (int i = 0; i < t.Length; i++)
- {
- if (t[i] == ' ')
- {
- s.Append(' ');
- continue;
- }
- s.Append(Convert.ToChar(t[i] + sh));
- }
- */
- for (int i = 0; i < s.Length; i++)
- {
- char c = char.ToLower(s[i]);
- int d = c - 'а';
- if (char.IsLetter(c))
- {
- cnt[c - 'а'].First++;
- }
- }
- cnt.Sort((y, x) => x.First.CompareTo(y.First));
- int k = 0;
- /* for (int i = 0; i < 8; i++)
- { Console.WriteLine($"{cnt[i].First} {Convert.ToChar(cnt[i].Second + 'а')}"); };
- */
- StringBuilder ans = NextPermutatuin(s, cnt[k++].Second);
- Console.WriteLine($"ans = {ans}");
- Console.WriteLine("enter \"1\" if text is done else enter any key");
- ConsoleKeyInfo cki = Console.ReadKey();
- while (cki.KeyChar != '1')
- {
- ans = NextPermutatuin(s, cnt[k++].Second);
- Console.WriteLine($"ans = {ans}");
- Console.WriteLine("enter \"1\" if text is done else enter any key");
- cki = Console.ReadKey();
- }
- Console.WriteLine($"ans = {ans}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement