-
-
Save Ph47/ae69edf0088ac215d225 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace ConsoleApp1 | |
{ | |
public class Program | |
{ | |
public void Main(string[] args) | |
{ | |
// Инициализация данных | |
int[][] A = new int [10][]; | |
Random r = new Random(); | |
for (int i = 0; i < A.Length; i++) | |
{ | |
A[i] = new int[15]; | |
A[i] = A[i].Select(j => r.Next()).ToArray(); | |
} | |
// Вызов заветной функции и присвоение результатов | |
KeyValuePair<int[], int[]> MS = MyCopypastedSolution(A); | |
int[] M = MS.Key; | |
int[] S = MS.Value; | |
// Вывод данных | |
Console.WriteLine("M:"); | |
Console.WriteLine(string.Join(",", M)); | |
Console.WriteLine("S:"); | |
Console.WriteLine(string.Join(",", S)); | |
Console.ReadLine(); | |
} | |
private KeyValuePair<int[], int[]> MyCopypastedSolution(int[][] A) | |
{ | |
// Инициализация массивов результата | |
KeyValuePair<int[], int[]> result = | |
new KeyValuePair<int[], int[]>(new int[A.Length], new int[A.Length]); | |
// Перебор строк | |
for (int i = 0; i < A.GetLength(0); i++) | |
{ | |
// Минимальное значение | |
result.Key[i] = A[i].Min(); | |
// Сумма индексов | |
result.Value[i] = A[i].ToList().IndexOf(result.Key[i]) + i; | |
} | |
return result; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment