Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.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 ConsoleApp1._8
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Random rnd = new Random();
  14. List<List<int>> array = new List<List<int>>(10);
  15. for (int i = 0; i < 10; i++)
  16. {
  17. array.Add(new List<int>(10));
  18. for (int j = 0; j < 10; j++)
  19. {
  20. array[i].Add(rnd.Next(-100, 100));
  21. if (array[i][j] == 0)
  22. {
  23. array[i][j] = 1;
  24. }
  25. }
  26.  
  27. }
  28.  
  29. for (int i = 0; i < 10; i++)
  30. {
  31. for (int j = 0; j < 10; j++)
  32. {
  33. Console.Write(array[i][j] + "\t ");
  34. }
  35. Console.WriteLine();
  36. }
  37.  
  38. var summ = Math.Abs(array[0][0]) + Math.Abs(array[0][1]) + Math.Abs(array[array.Count-1][array[array.Count-1].Count-1]);
  39. Console.WriteLine();
  40.  
  41. for (int i = 0; i < array.Count; i++)
  42. {
  43. for (int j = 0; j < array[i].Count; j++)
  44. {
  45. if(summ % array[i][j] == 0)
  46. {
  47. Console.WriteLine("Делитель :" + array[i][j]);
  48. array.Insert(i + 1, new List<int>(10));
  49. for (int c = 0; c < array[i].Count; c++)
  50. {
  51. array[i + 1].Add(0);
  52.  
  53. }
  54. i++;
  55. break;
  56. }
  57. }
  58. }
  59.  
  60. for (int i = 0; i < array.Count; i++)
  61. {
  62. for (int j = 0; j < array[i].Count; j++)
  63. {
  64. Console.Write(array[i][j] + "\t ");
  65. }
  66. Console.WriteLine();
  67. }
  68.  
  69. Console.WriteLine("Делимая сумма: " + summ);
  70. Console.ReadLine();
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement