Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CSLight
- {
- class Program
- {
- static void Main(string[] args)
- {
- int maxValue = int.MinValue,
- maxValueX = 0,
- maxValueY = 0;
- int[,] matrix = {
- { 1, 2, 3, 4, 5, 6, 7, 8, 9, 2 },
- { 5, 6, 2, 7, 4, 5, 12, 6, 8, 3 },
- { 10, 2, 4, 3, 6, 8, 5, 15, 13, 8 },
- { 17, 21, 3, 4, 2, 13, 9, 8, 9, 7 },
- { 5, 6, 2, 7, 4, 54, 12, 6, 8, 3 },
- { 10, 2, 4, 3, 6, 8, 51, 15, 13, 8 },
- { 17, 21, 38, 4, 2, 13, 9, 8, 9, 7 },
- { 17, 21, 3, 43, 2, 13, 9, 8, 9, 7 },
- { 5, 6, 2, 7, 4, 56, 12, 6, 8, 3 },
- { 10, 2, 4, 3, 6, 8, 5, 15, 13, 8 },
- };
- for (int y = 0; y < matrix.GetLength(0); y++)
- {
- for (int x = 0; x < matrix.GetLength(1); x++)
- {
- if (matrix[y, x] > maxValue)
- {
- maxValue = matrix[y, x];
- maxValueX = x;
- maxValueY = y;
- }
- }
- }
- Console.WriteLine("Максимальное значение в матрице - " + maxValue);
- Console.WriteLine("\nИсходная матрица: ");
- for (int y = 0; y < matrix.GetLength(0); y++)
- {
- for (int x = 0; x < matrix.GetLength(1); x++)
- {
- Console.Write(matrix[y, x] + " ");
- }
- Console.WriteLine();
- }
- matrix[maxValueY, maxValueX] = 0;
- Console.WriteLine("\nИзменённая матрица: ");
- for (int y = 0; y < matrix.GetLength(0); y++)
- {
- for (int x = 0; x < matrix.GetLength(1); x++)
- {
- Console.Write(matrix[y, x] + " ");
- }
- Console.WriteLine();
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement