Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. //вставить в массив модуль каждого отрицательного после него
  7. namespace zadacha5
  8. {
  9. class Program
  10. {
  11. static void Main()
  12. {
  13. Console.WriteLine("Введите размер массива");
  14. int size = Convert.ToInt32(Console.ReadLine());
  15. int[] mas = new int[2*size];
  16. Random rnd = new Random();
  17. for (int i = 0; i < size; i++)
  18. {
  19. mas[i] = rnd.Next(-100, 100);
  20. Console.Write(mas[i] + " ");
  21. }
  22. Console.WriteLine(" ");
  23. for (int i = 0; i < size; i++)
  24. {
  25. if (mas[i] < 0)
  26. {
  27. for (int j = mas.Length - 1; j > i + 1; j--)
  28. {
  29. mas[j] = mas[j - 1];
  30. }
  31. mas[i + 1] = Math.Abs(mas[i]);
  32. size++;
  33. i++;
  34. }
  35.  
  36. }
  37. for (int i = 0; i < size; i++)
  38. Console.Write(mas[i] + " ");
  39. Console.ReadKey();
  40. }
  41.  
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement