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 Les3
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Title = "3.4 Наибольшый элемент";
- int[,] arrMatrix = {
- { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 },
- { 2, 0, 6, 5, 8, 9, 3, 2, 3, 2 },
- { 3, 5, 11, 9, 78, 74, 3, 1, 2, 2 },
- { 4, 9, 6, 1, 2, 2, 3, 2, 9, 2 },
- { 5, 5, 60, 0, 2, 5, 3, 2, 7, 2 },
- { 6, 5, 6, 3, 8, 9, 3, 2, 0, 2 },
- { 7, 7, 79, 5, 9, 24, 3, 1, 9, 2 },
- { 8, 5, 6, 8, 2, 0, 3, 2, 4, 2 },
- { 9, 22, 6, 15, 2, 5, 13, 0, 2, 2 },
- { 0, 5, 6, 5, 2, 4, 3, 2, 9, 2 }
- };
- int iMax = 0;
- int x = 0;
- int y = 0;
- for (int i = 0; i < arrMatrix.GetLength(0); i++)
- {
- for (int j = 0; j < arrMatrix.GetLength(1); j++)
- {
- if(arrMatrix[i, j] > iMax)
- {
- iMax = arrMatrix[i, j];
- x = i;
- y = j;
- }
- }
- Console.WriteLine();
- }
- Console.SetCursorPosition(0, 0);
- for (int i = 0; i < arrMatrix.GetLength(0); i++)
- {
- for (int j = 0; j < arrMatrix.GetLength(1); j++)
- {
- Console.Write(arrMatrix[i, j] + " ");
- }
- Console.WriteLine();
- }
- Console.WriteLine();
- Console.WriteLine($"Наибольшее значение элементов матрицы: {iMax}");
- arrMatrix[x, y] = 0;
- Console.SetCursorPosition(0, arrMatrix.GetLength(0) + 4);
- for (int i = 0; i < arrMatrix.GetLength(0); i++)
- {
- for (int j = 0; j < arrMatrix.GetLength(1); j++)
- {
- Console.Write(arrMatrix[i, j] + " ");
- }
- Console.WriteLine();
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement