Advertisement
Sitisom

EVM8

Sep 23rd, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static int[] Input()
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int[] a = new int[n];
  15.             for (int i = 0; i < n; i++)
  16.             {
  17.                 a[i] = int.Parse(Console.ReadLine());
  18.             }
  19.             return a;
  20.         }
  21.         static int[,] Input2()
  22.         {
  23.             int n = int.Parse(Console.ReadLine());
  24.             int m = int.Parse(Console.ReadLine());
  25.             int[,] a = new int[n, m];
  26.             for (int i = 0; i < n; i++)
  27.             {
  28.                 for (int j = 0; j < m; j++)
  29.                 {
  30.                     a[i, j] = int.Parse(Console.ReadLine());
  31.                 }
  32.             }
  33.             return a;
  34.         }
  35.  
  36.         static void Print(int[] a)
  37.         {
  38.             for (int i = 0; i < a.Length; i++)
  39.             {
  40.                 Console.WriteLine(a[i]);
  41.             }
  42.         }
  43.  
  44.         static void Print(int[,] a)
  45.         {
  46.             for (int i = 0; i < a.GetLength(0); i++)
  47.             {
  48.                 for (int j = 0; j < a.GetLength(1); j++)
  49.                 {
  50.                     Console.WriteLine(a[i, j]);
  51.                 }
  52.             }
  53.         }
  54.  
  55.         static void Change(int[] a, int b)
  56.         {
  57.             for (int i = 0; i < a.Length; i++)
  58.             {
  59.                 if (a[i] < b)
  60.                 {
  61.                     a[i] = b;
  62.                 }
  63.             }
  64.         }
  65.  
  66.         static void Change(int[,] a, int b)
  67.         {
  68.             for (int i = 0; i < a.GetLength(0); i++)
  69.             {
  70.                 for (int j = 0; j < a.GetLength(1); j++)
  71.                 {
  72.                     if (b < a[i, j])
  73.                     {
  74.                         a[i, j] = b;
  75.                     }
  76.                 }
  77.             }
  78.         }
  79.  
  80.         static int Min(int[] a)
  81.         {
  82.             int min = a[0];
  83.             for (int i = 1; i < a.Length; i++)
  84.             {
  85.                 if (a[i] < min) min = a[i];
  86.             }
  87.             return min;
  88.         }
  89.  
  90.         static void PrintMinNumbers(int[] a, int min)
  91.         {
  92.             for (int i = 0; i < a.Length; i++)
  93.                 if (a[i] == min)
  94.                     Console.WriteLine(i);
  95.         }
  96.  
  97.         static void PrintDiagSum(int[,] a)
  98.         {
  99.             int k = 0;
  100.             int s = 0;
  101.             for(int i = 1; i< a.GetLength(0); i++)
  102.             {
  103.                 for( int j = 0; j < i; j++, k++)
  104.                 {
  105.                     s += a[i, j];
  106.                 }
  107.             }
  108.             Console.WriteLine(s * .0 / k);
  109.         }
  110.  
  111.         static int[] MinNumInCol(int[,] a)
  112.         {
  113.             int n = a.GetLength(0);
  114.             int[] b = new int[n];
  115.             for (int i = 0; i < n; i++)
  116.             {
  117.                 for (int j = 0; j < n; j++)
  118.                 {
  119.                     if (a[i, j] < b[j])
  120.                     {
  121.                         b[j] = a[i, j];
  122.                     }
  123.                 }
  124.             }
  125.             return b;
  126.         }
  127.  
  128.         static void Main(string[] args)
  129.         {
  130.             int k = int.Parse(Console.ReadLine());
  131.             int[] a = Input();
  132.             Print(a);
  133.             Change(a, k);
  134.            
  135.             Console.WriteLine("-----------------");
  136.  
  137.             int[,] b = Input2();
  138.             Print(b);
  139.             Change(b, k);
  140.             PrintMinNumbers(a, Min(a));
  141.             MinNumInCol(b);
  142.         }
  143.     }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement