mrfeedoz

Snejok 6 (6)

May 16th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 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 Sn_Bo_6__6_
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.Write("Введите размерность матрицы n: ");
  14.             int n = int.Parse(Console.ReadLine());
  15.             int m = n;
  16.             int[][] a = new int[n][];
  17.             for (int i = 0; i < n; ++i)
  18.             {
  19.                 a[i] = new int[n];
  20.                 for (int j = 0; j < m; ++j)
  21.                 {
  22.                     Console.Write("a[{0}][{1}]= ", i, j);
  23.                     a[i][j] = int.Parse(Console.ReadLine());
  24.                 }
  25.             }
  26.             for (int i = 0; i < n; ++i)
  27.             {
  28.                 for (int j = 0; j < m; ++j)
  29.                 {
  30.                     if (a[i][j] % 2 == 0)
  31.                         break;
  32.                     if(j==m-1)
  33.                     {
  34.                        for(int k=i;k<n-1;++k)
  35.                         {
  36.                             for (int l = 0; l < m; ++l)
  37.                             {
  38.                                 a[k][l] = a[k + 1][l];
  39.                             }
  40.                         }
  41.                         --i;
  42.                         --n;
  43.                     }
  44.                 }
  45.             }
  46.             Console.WriteLine("Конечная матрица: ");
  47.             for (int i = 0; i < n; ++i)
  48.             {
  49.                 for (int j = 0; j < m; ++j)
  50.                     Console.Write("{0} ", a[i][j]);
  51.                 Console.WriteLine();
  52.             }
  53.             Console.ReadKey();
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment