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 matrica
- {
- class Program
- {
- public static int[,] vector = new int[5,5];
- public static int counterLine = 0, Maxcounter = 0, Mincounter = 0, srednie;
- public static int[] min_index = new int[2], max_index = new int[2];
- static void Main(string[] args)
- {
- Random r = new Random();
- Console.WriteLine("Matrix: ");
- for (int i = 0; i < 5; i++)
- {
- for (int k = 0; k < 5; k++)
- {
- vector[i, k] = r.Next(25);
- counterLine++;
- Console.Write(vector[i, k] + " ");
- if (counterLine == 5)
- {
- Console.Write(System.Environment.NewLine);
- counterLine = 0;
- }
- }
- }
- Console.Write(System.Environment.NewLine);
- Mincounter = 300;
- for (int i = 0; i < 5; i++)
- for (int y = 0; y < 5; y++)
- Console.WriteLine("Index(" + i + ";" + y + ") = " + vector[i, y]);
- Console.Write(System.Environment.NewLine);
- for (int h = 0; h < 5; h++)
- for(int y = 0; y < 5; y++)
- {
- if (vector[h, y] > Maxcounter) { Maxcounter = vector[h, y]; max_index[0] = h; max_index[1] = y; }
- if (vector[h, y] < Mincounter) { Mincounter = vector[h, y]; min_index[0] = h; min_index[1] = y; }
- }
- Console.WriteLine("Max index(" + max_index[0].ToString() + ";" + max_index[1].ToString() + ")");
- Console.WriteLine("Min index(" + min_index[0].ToString() + ";" + min_index[1].ToString() + ")");
- Console.Write(System.Environment.NewLine);
- for (int i = 0; i < 5; i++)
- for(int j = 0; j < 5; j++)
- srednie += vector[i, j];
- float result = srednie / 2;
- Console.WriteLine("Сума значений матрицы: " + srednie.ToString());
- Console.WriteLine("Средние значение матрицы: " + result.ToString());
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement