Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Buggy Sorting Code - for Processing.js
- // defining the array
- int cheesesticks [] = {21, 33, 44, 22 ,55 ,66 ,77, 33, 22, 11, 44, 33, 22, 11, 55 ,66, 5, 2, 100, 20};
- // counters
- int i = -1;
- int j = 0;
- // storing the minimum
- int min;
- // setup runs once
- void setup () {
- size (800,800);
- for (int k=0; k<20; k++)
- println(cheesesticks[i]);
- }
- // runs foreverrrrr! (not really)
- void draw () {
- background(0);
- // only runs after j reaches 20
- if ((j == 20) && (i < 19)) {
- i++;
- j=i+1;
- min = cheesesticks[i];
- }
- // runs as long as j is less than 20
- if (j < 20) {
- if (cheesesticks[j] < min){
- min = cheesesticks[j];
- int temp = cheesesticks[i];
- cheesesticks[i] = cheesesticks[j];
- cheesesticks[j] = temp;
- }
- j++;
- }
- // Draws the state of the cheesesticks
- fill (0,0,255);
- for (int l=0; l<20; l++)
- {
- rect(0, l*20, cheesesticks[l]*5, 10);
- }
- println("poop");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement