Advertisement
DaniPasteBin

Untitled

Jun 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _05.MagicExchangeableWords
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             //Вариант 2- не хваща всички случаи
  12.             string[] input = Console.ReadLine().Split(' ').ToArray();
  13.             string word1 = input[0];
  14.             string word2 = input[1];
  15.  
  16.             //сравняваме само уникалните символи
  17.             int w1 = word1.ToCharArray().Distinct().Count();//трие всички повтарящи се членове, в случая символи (заложено е сравнение)
  18.             int w2 = word2.ToCharArray().Distinct().Count();// и в този стринг трие повторенията
  19.  
  20.             if (w1 == w2)  //сравняват се дължините на неповтарящите се cw
  21.             {
  22.                 Console.WriteLine("true");
  23.             }
  24.             else
  25.             {
  26.                 Console.WriteLine("false");
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement