Advertisement
radostina92

Задача2

May 12th, 2022
828
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. // алтернативно решение с linq библиотеката
  2.  
  3. int[] inputArray = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
  4.  
  5. int m = inputArray[0];
  6. int l = inputArray[1];
  7.  
  8.  
  9. int[] resultArray = new int[l];
  10. for (int i = 0; i < l; i++)
  11. {
  12.     int[] array = new int[m];
  13.    
  14.     int[] input = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
  15.    
  16.     for (int j = 0; j < input.Length; j++)
  17.     {
  18.         array[j] = input[j];
  19.  
  20.         if(j == 0)
  21.         {
  22.             continue;
  23.         }
  24.         else
  25.         {
  26.             array[input.Length - j] = array[j - 1] + array[j];
  27.         }
  28.     }
  29.  
  30.     resultArray[i] = array.Max();
  31. }
  32.  
  33. Console.WriteLine(resultArray.Max());
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement