Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int[,] a = new int[10,10];
- Random rand = new Random();
- for (int i = 0; i < a.GetLength(0); i++)
- {
- for (int j=0; j < a.GetLength(1);j++)
- {
- a[i, j] = rand.Next(0,100);
- }
- }
- int max = a[0,0], maxI=0, maxJ=0;
- for (int i = 0; i < a.GetLength(0); i++)
- {
- for (int j = 0; j < a.GetLength(1); j++)
- {
- if(max< a[i, j])
- {
- max = a[i, j];
- maxI = i;
- maxJ = j;
- }
- }
- }
- Console.WriteLine("Исходная матрица");
- for(int i = 0; i < a.GetLength(0); i++)
- {
- for (int j = 0; j < a.GetLength(1); j++)
- {
- Console.Write(a[i, j]+" ");
- }
- Console.Write("\n");
- }
- Console.WriteLine("Максимальное число = " + max);
- Console.WriteLine("Текущая матрица");
- for (int i = 0; i < a.GetLength(0); i++)
- {
- for (int j = 0; j < a.GetLength(1); j++)
- {
- if (maxI == i && maxJ == j)
- Console.Write(0 + " ");
- Console.Write(a[i, j] + " ");
- }
- Console.Write("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement