NedyalkoKikov

CompareCharArrays

Jun 1st, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 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 CompareCharArr
  8. {
  9. class CompareCharArrays
  10. {
  11. static void Main()
  12. {
  13. char[] firstArr = Console.ReadLine().Split().Select(char.Parse).ToArray();
  14. char[] secondArr = Console.ReadLine().Split().Select(char.Parse).ToArray();
  15. int smallerArr = Math.Min(firstArr.Length, secondArr.Length);
  16. bool areEqual = false;
  17. for (int i = 0; i < smallerArr; i++)
  18. {
  19. if(firstArr[i] == secondArr[i])
  20. {
  21. continue;
  22. }
  23. else if(firstArr[i] < secondArr[i])
  24. {
  25. Console.WriteLine(firstArr);
  26. Console.WriteLine(secondArr);
  27. }
  28. else
  29. {
  30. Console.WriteLine(secondArr);
  31. Console.WriteLine(firstArr);
  32. }
  33.  
  34.  
  35. areEqual = true;
  36. break;
  37. }
  38. if (!areEqual)
  39. {
  40. if(firstArr.Length <= secondArr.Length)
  41. {
  42. Console.WriteLine(firstArr);
  43. Console.WriteLine(secondArr);
  44. }
  45. else
  46. {
  47. Console.WriteLine(secondArr);
  48. Console.WriteLine(firstArr);
  49. }
  50. }
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment