Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace myloyorrr
- {
- internal class Program
- {
- static void In(int[][] a, int n, int m)
- {
- for (int i = 0; i < n; i++)
- {
- string[] s = Console.ReadLine().Split();
- for (int j = 0; j < m; j++)
- {
- a[i][j] = int.Parse(s[j]);
- }
- }
- }
- static void delst(int[][] a, ref int n, int m, int k)
- {
- for (int i = k; i < n-1; i++)
- {
- a[i] = a[i + 1];
- }
- n--;
- }
- static void delsb(int[][] a, ref int m, int n, int k)
- {
- for (int x = 0; x < n; x++)
- {
- for (int y = k; y < m - 1; y++)
- {
- a[x][y] = a[x][y + 1];
- }
- }
- m--;
- }
- static void Out(int[][] a, int n, int m)
- {
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- Console.Write(a[i][j] + " ");
- }
- Console.WriteLine();
- }
- }
- static void Main()
- {
- int[][] a;
- int n = int.Parse(Console.ReadLine());
- int m = int.Parse(Console.ReadLine());
- a = new int[n][];
- for (int i = 0; i < n; i++)
- {
- a[i] = new int[m];
- }
- In(a, n, m);
- for (int i = 0; i < n; i++) // проверка строк
- {
- bool f = true;
- for (int j = 0; j < m; j++)
- {
- if (a[i][j] != 0)
- {
- f = false;
- break;
- }
- }
- if (f == true)
- {
- delst(a, ref n, m, i);
- i--;
- }
- }
- //Out(a, n, m);
- for (int j = 0; j < m; j++) // проверка столбцов
- {
- //Console.WriteLine(j);
- bool f = true;
- for (int i = 0; i < n; i++)
- {
- if (a[i][j] != 0)
- {
- f = false;
- break;
- }
- }
- if (f == true)
- {
- delsb(a, ref m, n, j);
- j--;
- }
- //Out(a, n, m);
- }
- Out(a, n, m);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement