Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace I5_21
- {
- class Program
- {
- static void Main(string[] args)
- {
- string a = Console.ReadLine();
- string b = Console.ReadLine();
- if (a == b)
- {
- Console.WriteLine("Възможно е!");
- }
- else if (a.Length < b.Length)
- {
- Console.WriteLine("Не е възможно!");
- }
- else
- {
- char[] letters = new char[a.Length];
- for (int i = 0; i < a.Length; i++)
- {
- letters[i] = a[i];
- }
- bool isWordFound = true;
- for (int i = 0; i < b.Length; i++)
- {
- int index = a.IndexOf(b[i]);
- if (index != -1)
- {
- if (letters[index] != '0')
- {
- letters[index] = '0';
- }
- else
- {
- bool letterFound = false;
- index = a.IndexOf(b[i], index + 1);
- while (index != -1)
- {
- if (letters[index] != '0')
- {
- letters[index] = '0';
- letterFound = true;
- break;
- }
- index = a.IndexOf(b[i], index + 1);
- }
- if (letterFound == false)
- {
- Console.WriteLine("Не е възможно!");
- isWordFound = false;
- break;
- }
- }
- }
- else
- {
- Console.WriteLine("Не е възможно!");
- isWordFound = false;
- break;
- }
- }
- if (isWordFound == true)
- {
- Console.WriteLine("Възможно е!");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment