Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Carros[] carritos=new Carros[10];
- void setup() {
- size(900, 600);
- for (int i=0; i<carritos.length; i++) {
- carritos[i]=new Carros(color(random(255), random(255), random(255)), 0, (height/10*i), random(10));
- }
- }
- void draw() {
- background(200);
- for (int i=0; i<10; i++) {
- carritos[i].mostrar();
- carritos[i].veloc();
- }
- }
- void quickSort(float arr[], int begin, int end) {
- if (begin < end) {
- int partitionIndex = partition(arr, begin, end);
- quickSort(arr, begin, partitionIndex-1);
- quickSort(arr, partitionIndex+1, end);
- }
- }
- int partition(float arr[], int begin, int end) {
- float pivot = arr[end];
- int i = (begin-1);
- for (int j = begin; j < end; j++) {
- if (arr[j] <= pivot) {
- i++;
- float swapTemp = arr[i];
- arr[i] = arr[j];
- arr[j] = swapTemp;
- }
- }
- float swapTemp = arr[i+1];
- arr[i+1] = arr[end];
- arr[end] = swapTemp;
- return i+1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement