Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Arrays
- {
- class Program
- {
- static void Main(string[] args)
- {
- int rows = int.Parse(Console.ReadLine());
- int cols = int.Parse(Console.ReadLine());
- int[,] intMatrix = new int[rows, cols];
- for (int row = 0; row < rows; row++)
- { //1 2 3 5
- int[] numbersRow = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- for (int col = 0; col < cols; col++)
- {
- intMatrix[row, col] = numbersRow[col];
- }
- }
- for (int col = 0; col < cols; col++)
- {
- int min = int.MaxValue;
- for (int row = 0; row < rows; row++)
- {
- int currentElement = intMatrix[row, col];
- if(currentElement < min)
- {
- min = currentElement;
- }
- }
- Console.WriteLine("Min number in column " + col + ": " + min);
- }
- }
- static void printMatrix(int [,] intMatrix)
- {
- for (int row = 0; row < intMatrix.GetLength(0); row++)
- {
- for (int col = 0; col < intMatrix.GetLength(1); col++)
- {
- Console.Write(intMatrix[row, col] + " ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment