asjfda

by fsdf on March 19th, 2012
No notes
Syntax: No syntax
Show lines - Hide lines - Show in textbox - Download
  1. void sortArray(int sortedArray[])
  2. {
  3. //Create variables
  4. bool flag = 0;
  5. int temp, counter;
  6.  
  7. //Start a loop to sort the array, continues until array is in order
  8. while (flag == 0)
  9. {
  10. //Counter that keeps track of number values in the correct order
  11. counter = 0;
  12.  
  13. //Runs through every value in the array
  14. for (int i = 0; i < paleSize - 1; i++)
  15. {
  16. //
  17. if (sortedArray[i] > sortedArray[i + 1])
  18. {
  19. temp = sortedArray[i];
  20. sortedArray[i] = sortedArray[i + 1];
  21. sortedArray[i + 1] = temp;
  22. }
  23. else
  24. counter++;
  25. }
  26. if (counter == (paleSize - 1))
  27. break;
  28. else
  29. continue;
  30. }
  31. for (int i = 0; i < paleSize; i++)
  32. {
  33. cout << sortedArray[i] << endl;
  34. }
  35.  
  36. }

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS