dhows

Untitled

Mar 8th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. class Program
  2. {
  3. public static void Main()
  4. {
  5. Console.Write("Enter n: ");
  6. int n = int.Parse(Console.ReadLine());
  7.  
  8. string[] cities = new string[n];
  9. for (int i = 0; i < n; i++)
  10. {
  11. Console.Write("Enter city: ");
  12. cities[i] = Console.ReadLine();
  13. }
  14.  
  15. bool isRight = true;
  16. for (int i = 0; i < n; i++)
  17. {
  18. isRight = false;
  19. string[] args = cities[i].Trim().Split(' ');
  20. if (args.Length == 2)
  21. {
  22. isRight = true;
  23. }
  24.  
  25. if (args.Length > 2)
  26. {
  27. int counter = 0;
  28. for (int j = 0; j < args.Length; j++)
  29. {
  30. if (args[j] != "")
  31. {
  32. counter++;
  33. }
  34. }
  35. if (counter == 2)
  36. {
  37. isRight = true;
  38. }
  39. }
  40. if (isRight)
  41. {
  42. Console.WriteLine(cities[i]);
  43. }
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment