Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp12
- {
- class Program
- {
- static void Main(string[] args)//Lukonkina
- {
- const int x = 7, y = 5;
- int[,] a = new int[x, y];
- int MaxIndexJ = 0; // номер в столбце
- int MaxIndexI = 0; // номер в строке
- Random r = new Random();
- for (int i = 0; i < x; i++)
- {
- for (int j = 0; j < y; j++)
- {
- a[i, j] = r.Next(11);
- }
- }
- Console.WriteLine("Исходный массив");
- for (int i = 0; i < x; i++)
- {
- for (int j = 0; j < y; j++)
- {
- Console.Write("{0,4} ", a[i, j]);
- }
- Console.WriteLine();
- }
- Console.WriteLine();
- int max = int.MinValue;
- for (int i = 0; i < y; i++) // коор-та х
- {
- max = int.MinValue;
- for (int j = 0; j < x; j++) // коор-та у
- {
- if (a[j, i] > max)
- {
- max = a[j, i];
- MaxIndexI = i;
- MaxIndexJ = j;
- }
- }
- Console.WriteLine("max = {0} ({1},{2})", max, MaxIndexJ, MaxIndexI);
- if (max < (a[i, 0] + a[i, y-1])/2)
- {
- a[MaxIndexJ, MaxIndexI] = (a[i, 0] + a[i, y-1]) / 2;
- }
- else
- {
- a[MaxIndexJ, MaxIndexI] = MaxIndexJ;
- }
- MaxIndexJ = 0;
- MaxIndexI = 0;
- }
- Console.WriteLine("\nИзмененный массив");
- for (int i = 0; i < x; i++)
- {
- for (int j = 0; j < y; j++)
- {
- Console.Write("{0,4} ", a[i,j]);
- }
- Console.WriteLine();
- }
- Console.Read();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement