Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace _9._6
- {
- class Program
- {
- static void Main(string[] args)
- { // ввод строк
- string stroka1 = Console.ReadLine();
- string stroka2 = Console.ReadLine();
- Console.Write(CanBePermutated(stroka1, stroka2));
- Console.ReadKey();
- }
- public static bool CanBePermutated(string s1, string s2)
- {
- //проверка на равность строк
- if (s1.Length != s2.Length)
- {
- return false;
- }
- bool isDeleted = false;
- for (int i = 0; i < s1.Length; i++)
- {
- for (int j = 0; j < s2.Length; j++)
- if (s2[j] == s1[i])
- {
- isDeleted = true;
- s2 = s2.Remove(j, 1);
- }
- // если обнаружили несовпадение
- if (!isDeleted)
- break;
- }
- return isDeleted;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement