Advertisement
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;
- //вставить в массив модуль каждого отрицательного после него
- namespace zadacha5
- {
- class Program
- {
- static void Main()
- {
- Console.WriteLine("Введите размер массива");
- int size = Convert.ToInt32(Console.ReadLine());
- int[] mas = new int[2*size];
- Random rnd = new Random();
- for (int i = 0; i < size; i++)
- {
- mas[i] = rnd.Next(-100, 100);
- Console.Write(mas[i] + " ");
- }
- Console.WriteLine(" ");
- for (int i = 0; i < size; i++)
- {
- if (mas[i] < 0)
- {
- for (int j = mas.Length - 1; j > i + 1; j--)
- {
- mas[j] = mas[j - 1];
- }
- mas[i + 1] = Math.Abs(mas[i]);
- size++;
- i++;
- }
- }
- for (int i = 0; i < size; i++)
- Console.Write(mas[i] + " ");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement