Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. try
  4. {
  5. int[][] MyArray;
  6. Console.Write("Введите количество строк: ");
  7. int n = int.Parse(Console.ReadLine());
  8. MyArray = new int[n][];
  9. MakeArray(MyArray);
  10. PrintArray("исходный массив:", MyArray);
  11. for (int i = 0; i < MyArray.Length; i++) Array.Sort(MyArray[i]);
  12. PrintArray("измененный массив", MyArray);
  13. }
  14. catch (FormatException)
  15. {
  16. Console.WriteLine("неверный формат ввода данных");
  17. }
  18. catch (OverflowException)
  19. {
  20. Console.WriteLine("переполнение");
  21. }
  22. catch (OutOfMemoryException)
  23. {
  24. Console.WriteLine("недостаточно памяти для создания нового объекта");
  25. }
  26. }
  27.  
  28. static void MakeArray(int[][] mas)
  29. {
  30. for (int i = 0; i < mas.Length; ++i)
  31. {
  32. mas[i] = new int[i + 1 * 2];
  33. for (int j = 0; j < mas[i].Length; j++)
  34. mas[i][j] = i + j + 1;
  35. }
  36. }
  37.  
  38. static void PrintArray(string a, int[][] mas)
  39. {
  40. Console.WriteLine(a);
  41. Console.WriteLine("0");
  42. for (int i = 0; i < mas.Length; i++)
  43. {
  44. for (int j = 0; j < mas[i].Length; j++) Console.Write("{0} ", mas[i][j]);
  45. Console.WriteLine();
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement