Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. static int[] ReadIntArray()
  2. {
  3. int[] numsArray;
  4. bool flag = false;
  5. do
  6. {
  7. flag = true;
  8. string buff = Console.ReadLine();
  9. numsArray = new int[buff.Split(' ').Length];
  10.  
  11. if (buff.Split(' ').Length > 120 || buff.Split(' ').Length < 1)
  12. {
  13. Console.WriteLine("Введите числа ещё раз, позязя!");
  14. flag = false;
  15. continue;
  16. }
  17.  
  18. int i = 0;
  19. foreach (var item in buff.Split(' '))
  20. {
  21. if (!int.TryParse(item, out numsArray[i])
  22. || Math.Abs(numsArray[i]) > 1025)
  23. {
  24. Console.WriteLine("Введите числа ещё раз, позязя!");
  25. flag = false;
  26. continue;
  27. }
  28. i++;
  29. }
  30.  
  31. } while (!flag);
  32.  
  33.  
  34. return numsArray;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement