Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp2
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int probel1 = 1, probel2 = 1;
  14. Console.WriteLine("Введите два слова через пробел");
  15. string s = Console.ReadLine();
  16. char[] arr = s.ToCharArray();
  17. for (int i = 1; i < arr.Length; i++)
  18. {
  19. if (arr[i] == ' ')
  20. {
  21. if (probel1 <= 1) { probel1 = i; probel2 = i; }
  22. else probel2 = i;
  23. }
  24. }
  25. Console.WriteLine("Введите количество букв второго слова");
  26. int numb = int.Parse(Console.ReadLine());
  27. if (arr[probel1 - 1] == arr[probel2 + numb]) Console.WriteLine("{0} и {1} совпадают", s[probel1 - 1], s[probel2 + numb]);
  28. else Console.WriteLine("{0} и {1} не совпадают", s[probel1 - 1], s[probel2 + numb]);
  29. Console.ReadLine();
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement