Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace homework
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random rand = new Random();
- int[,] A = {
- {0,0,0,0,0,0,0,0,0,0, },
- {0,0,0,0,0,0,0,0,0,0, },
- {0,0,0,0,0,0,0,0,0,0, },
- {0,0,0,0,0,0,0,0,0,0, },
- {0,0,0,0,0,0,0,0,0,0, },
- {0,0,0,0,0,0,0,0,0,0, },
- {0,0,0,0,0,0,0,0,0,0, },
- {0,0,0,0,0,0,0,0,0,0, },
- {0,0,0,0,0,0,0,0,0,0, },
- {0,0,0,0,0,0,0,0,0,0, },
- };
- Console.WriteLine("Исходная матрица:");
- for (int i=0; i< A.GetLength(0);i++)
- {
- for (int j=0; j< A.GetLength(1);j++)
- {
- A[i,j]=rand.Next(10, 100);
- Console.Write(A[i, j]+" ");
- }
- Console.WriteLine();
- }
- int maxValue = int.MinValue;
- int[] coor = new int[2];
- for (int i=0; i< A.GetLength(0);i++)
- {
- for (int j=0; j< A.GetLength(1);j++)
- {
- if (A[i, j] > maxValue)
- {
- maxValue = A[i, j];
- coor[0] = i;
- coor[1] = j;
- }
- }
- }
- A[coor[0], coor[1]] = 0;
- Console.WriteLine("\nМаксимальное значение в матрице = "+maxValue);
- Console.WriteLine("\nПолученная матрица: ");
- for (int i = 0; i < A.GetLength(0); i++)
- {
- for (int j = 0; j < A.GetLength(1); j++)
- {
- Console.Write(A[i, j] + " ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement