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 arraytask3
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random rand = new Random();
- int[,] aMatrix = new int[10, 10];
- int maxNumber = int.MinValue;
- for (int i = 0; i < aMatrix.GetLength(0); i++)
- {
- for (int j = 0; j < aMatrix.GetLength(1); j++)
- {
- aMatrix[i,j] = rand.Next(100, 1000);
- }
- }
- Console.WriteLine("Дана матрица А:\n");
- for (int i = 0; i < aMatrix.GetLength(0); i++)
- {
- for (int j = 0; j < aMatrix.GetLength(1); j++)
- {
- Console.Write(aMatrix[i,j] + " ");
- }
- Console.WriteLine();
- }
- for (int i = 0; i < aMatrix.GetLength(0); i++)
- {
- for (int j = 0; j < aMatrix.GetLength(1); j++)
- {
- if (maxNumber < aMatrix[i,j])
- {
- maxNumber = aMatrix[i, j];
- }
- }
- }
- Console.WriteLine("\nНаибольший элемент матрицы: " + maxNumber);
- Console.WriteLine("\n\nПолученная матрица с заменой максимального числа на 0:\n");
- for (int i = 0; i < aMatrix.GetLength(0); i++)
- {
- for (int j = 0; j < aMatrix.GetLength(1); j++)
- {
- if (aMatrix[i, j] == maxNumber)
- {
- aMatrix[i, j] = 0;
- Console.ForegroundColor = ConsoleColor.Red;
- }
- Console.Write(aMatrix[i, j] + " ");
- Console.ForegroundColor = ConsoleColor.White;
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement