Schnuk

Untitled

May 18th, 2021 (edited)
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Meshok_s_troubles
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Console.WriteLine("Введите размеры матрицы");
  11.             int n = int.Parse(Console.ReadLine());
  12.             Console.WriteLine("Введите элементы");
  13.             var list = new List<List<int>>();
  14.              
  15.             for (int i = 0; i < n; i++)
  16.             {
  17.                 list.Add(new List<int>());
  18.                 for (int j = 0; j < n; j++)
  19.                     list[i].Add(int.Parse(Console.ReadLine()));
  20.             }
  21.  
  22.             for (int i = 0; i < n; i++)
  23.                 for (int j = n - 1; j > i; j--)
  24.                 {
  25.                     if (list[i][j] == 0)
  26.                     {
  27.                         list[i].Clear();
  28.                         break;
  29.                     }
  30.                 }
  31.  
  32.             for (int i = 0; i < list.Count; i++)
  33.                 for (int j = 0; j < list[i].Count; j++)
  34.                 {
  35.                     Console.Write(list[i][j]);
  36.                     if (j == n - 1)
  37.                         Console.WriteLine();
  38.                 }    
  39.         }
  40.     }
  41. }
Add Comment
Please, Sign In to add comment