Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class ArrayGenerator : MonoBehaviour
  6. {
  7. public float[] GenerateArray(float[] array, int arrayLen)
  8. {
  9. array = new float[arrayLen];
  10. for (int i = 0; i < arrayLen; i++)
  11. {
  12. array[i] = Random.Range(0.0f, 1.0f);
  13. }
  14. return array;
  15. }
  16. public float[] SortArray(float[] array, int arrayLen)
  17. {
  18. for (int i = 0; i < arrayLen; i++)
  19. {
  20. for (int j =0; j < arrayLen; j++)
  21. {
  22. if (array[i] > array[j])
  23. {
  24. float buffer = array[i];
  25. array[i] = array[j];
  26. array[j] = buffer;
  27. }
  28. }
  29. }
  30.  
  31. return array;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement