Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleAppCSharp
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Введите ширину массива: ");
- int N = int.Parse(Console.ReadLine());
- Console.Write("Введите длинну массива: ");
- int M = int.Parse(Console.ReadLine());
- //Console.Write("Введите диапазон массива: ");
- //Console.Write("\n\tВведите минимальное число: ");
- //int A = int.Parse(Console.ReadLine());
- //Console.Write("\n\tВведите максимальное число: ");
- //int B = int.Parse(Console.ReadLine());
- Console.WriteLine();
- int[,] arr = new int[M, N];
- Random a = new Random();
- for(int i = 0; i < arr.GetLength(0); i++)
- {
- for(int j = 0; j < arr.GetLength(1); j++)
- {
- arr[i, j] = a.Next(-10, 10);
- }
- }
- for(int i = 0; i < arr.GetLength(0); i++)
- {
- for(int j = 0; j < arr.GetLength(1); j++)
- {
- Console.Write("\t" + arr[i, j]);
- }
- Console.WriteLine();
- }
- Console.Write("\n");
- int tmp;
- int k=0;
- for(int j = 0; j < arr.GetLength(0) - 1; j++)
- {
- for(int i = 0; i < arr.GetLength(1); i++)
- {
- if(j % 2 != 0)
- {
- k = 0;
- if(arr[i, j] < 0)
- {
- tmp = arr[k, j];
- arr[0+k, j] = arr[i, j];
- arr[0+i, j] = tmp;
- k++;
- }
- }
- }
- }
- for(int i = 0; i < arr.GetLength(0); i++)
- {
- for(int j = 0; j < arr.GetLength(1); j++)
- {
- Console.Write("\t" + arr[i, j]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment