Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int[,] mas = new int[10, 10];
  10.             Random Gen = new Random();
  11.             int i = 0;
  12.             do
  13.             {
  14.                 int j = 0;
  15.                 do
  16.                 {
  17.                     mas[i, j] = Gen.Next(0, 100);
  18.                     j++;
  19.                 } while (mas.GetLength(1) > j);
  20.                 i++;
  21.             } while (mas.GetLength(0) > i);
  22.  
  23.             Console.WriteLine("\t\t\t\tЭлементы массива");
  24.  
  25.             i = 0;
  26.             do
  27.             {
  28.                 int j = 0;
  29.                 do
  30.                 {
  31.                     Console.Write("{0,8}", mas[i, j]);
  32.                     j++;
  33.                 } while (mas.GetLength(1) > j);
  34.                 i++;
  35.                 Console.WriteLine();
  36.             } while (mas.GetLength(0) > i);
  37.  
  38.             int сумма = 0;
  39.             i = 0;
  40.             do
  41.             {
  42.                 int j = 0;
  43.                 do
  44.                 {
  45.                     сумма += mas[i, j];
  46.                     j++;
  47.                 } while (mas.GetLength(1) > j);
  48.                 i++;
  49.             } while (mas.GetLength(0) > i);
  50.             Console.WriteLine("Сумма элементов массива = {0}", сумма);
  51.  
  52.             int[] maxNumbers = new int[10];
  53.             for (i = 0; i < mas.GetLength(0); i++)
  54.             {
  55.                 for (int j = 0; j < mas.GetLength(1); j++)
  56.                 {
  57.                     if (maxNumbers[i] < mas[i, j])
  58.                     {
  59.                         maxNumbers[i] = mas[i, j];
  60.                     }
  61.                 }
  62.             }
  63.             foreach (var maxNumber in maxNumbers)
  64.             {
  65.                 Console.WriteLine(maxNumber);
  66.             }
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement