Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- //GetLength(1)-столбцы
- static void Main(string[] args)
- {
- /*************ИНИЦИАЛИЗАЦИЯ***************/
- Console.Write("Enter ebaniy razmer strok:");
- int n = int.Parse(Console.ReadLine());
- Console.Write("Enter ebaniy razmer stolbov:");
- int m = int.Parse(Console.ReadLine());
- int[,] mas = new int[n, m];
- /****************ВВОД*********************/
- for (int i = 0; i < mas.GetLength(0); i++)
- {
- for (int j = 0; j < mas.GetLength(1); j++)
- {
- Console.Write("mas[{0},{1}]= ", i, j);
- mas[i, j] = int.Parse(Console.ReadLine());
- }
- }
- int[,] mas2 = (int[,])mas.Clone();//создали второй массив
- /*********ПОШЛА_ЖАРА******************/
- if (mas.GetLength(1) % 2 == 0)
- {
- for (int i = 0; i < mas.GetLength(0); i++)
- {
- for (int j = 0; j < mas.GetLength(1); j++)
- {
- mas[i, j / 2] = mas2[i, (j / 2) + 1];
- mas[i, (j / 2) + 1] = mas2[i, (j / 2)];
- }
- }
- }
- else
- {
- for (int i = 0; i < mas.GetLength(0); i++)
- {
- for (int j = 0; j < mas.GetLength(1); j++)
- {
- mas[i, 0] = mas2[i, (byte)Math.Round(j / 2.0)];
- mas[i, (byte)Math.Round(j / 2.0)] = mas2[i, 0];
- }
- }
- }
- /********************ВЫВОД*****************/
- for (int i = 0; i < mas.GetLength(0); i++)
- {
- for (int j = 0; j < mas.GetLength(1); j++)
- {
- Console.Write("{0} ", mas[i, j]);
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment