Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. public static int[] IniTaula(int n)
  2. {
  3. int[] t = new int[n];
  4. for (int i = 0; i < t.Length; i++)
  5. {
  6. t[i] = i + 1;
  7. }
  8. return t;
  9. }
  10. public static void Desordenar(int[] t, int valor)
  11. {
  12. Random number = new Random();
  13. int random1, random2, aux;
  14.  
  15. for (int i = 0; i < valor; i++)
  16. {
  17. random1 = number.Next(t.Length);
  18. random2 = number.Next(t.Length);
  19. aux = t[random1];
  20. t[random1] = t[random2];
  21. t[random2] = aux;
  22. }
  23.  
  24. }
  25. public static void ExtreureBoles(int[] t)
  26. {
  27. for (int i = 0; i < t.Length; i++)
  28. {
  29. Console.WriteLine("EXRACCIÓ {0} : BOLA NUM {1}", i + 1, t[i]);
  30. Console.ReadKey();
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement