Сделать вывод матрицы по-другому - C#
Формулировка задачи:
Подскажите пожалуйста, что здесь не правильно? Мне сказали вывод матрицы нужно сделать по другому.
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication8
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n, m;
- Console.WriteLine("Введите размер матрицы n*m: ");
- n = int.Parse(Console.ReadLine());
- m = int.Parse(Console.ReadLine());
- int [,] a = new int [n, m];
- int min = Int32.MaxValue;
- int max = -1*min;
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- Console.Write("Введите элемент матрицы: ");
- a[i, j] = Convert.ToInt32(Console.ReadLine());
- {
- if (max < a[i, j]) max = a[i, j];
- if (min > a[i, j]) min = a[i, j];
- }
- }
- }
- Console.Write("Среднее арифметическое: ", (max + min)/2);
- Console.Read();
- }
- }
- }
Решение задачи: «Сделать вывод матрицы по-другому»
textual
Листинг программы
- using System;
- namespace ConsoleApplication8
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n, m;
- Console.WriteLine("Введите размер матрицы n*m: ");
- n = int.Parse(Console.ReadLine());
- m = int.Parse(Console.ReadLine());
- int[,] a = new int[n, m];
- int min = Int32.MaxValue;
- int max = -1 * min;
- Random rnd = new Random();
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- a[i, j] = rnd.Next(100);
- {
- if (max < a[i, j]) max = a[i, j];
- if (min > a[i, j]) min = a[i, j];
- }
- }
- }
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- Console.Write(a[i, j] + " ");
- }
- Console.WriteLine();
- }
- Console.WriteLine("Среднее арифметическое: {0}", (max + min) / 2);
- Console.ReadKey();
- }
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д