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 = 5, y = 7;
- 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 < x; i++) // коор-та х
- {
- max = int.MinValue;
- for (int j = 0; j < y; j++) // коор-та у
- {
- if (a[i, j] > max)
- {
- max = a[i, j];
- MaxIndexI = i;
- MaxIndexJ = j;
- }
- }
- Console.WriteLine("max = {0} ({1},{2})", max,MaxIndexI, MaxIndexJ);
- if (max < (a[i, 0] + a[i, y-1])/2)
- {
- a[MaxIndexI, MaxIndexJ] = (a[i, 0] + a[i, y-1]) / 2;
- }
- else
- {
- a[MaxIndexI, MaxIndexJ] = MaxIndexJ;
- }
- MaxIndexI = 0;
- MaxIndexJ = 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