Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _4._6
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int[] mas = new int[] { 1, 2, 3, 4, 5, 6, 7 };
  10. a(ref mas);
  11. }
  12. static int a(ref int[] b)
  13. {
  14. bool vhod = true;
  15. int[] count = new int[b.Length];
  16. int[] rememeber = new int[b.Length];
  17. for (int i = 0; i < b.Length; i++)
  18. {
  19. rememeber[i] = b[i];
  20. }
  21. Random random = new Random();
  22. int r1 = random.Next(1, b.Length);
  23. for (int i = 0; i < b.Length; i++)
  24. {
  25. for (int l = 0; l < i; l++)
  26. {
  27. vhod = true;
  28. if (count[l] == r1)
  29. {
  30. i -= 1;
  31. vhod = false;
  32. continue;
  33. }
  34. }
  35. if (vhod == true)
  36. {
  37. b[i] = rememeber[r1];
  38. count[i] = r1;
  39. }
  40. }
  41. for (int i = 0; i < b.Length; i++)
  42. {
  43. Console.WriteLine(b[i]);
  44. }
  45. return b[1];
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement