Thefaceofbo

bubbleSort (C)

Nov 10th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. int bubbleSort(int *A, int len) {
  2.    int temp,x,y = 0;
  3.    if (A == NULL) { return -1; }
  4.    if (len == 1) { return 0; }
  5.    for (x=0; x < len; x++) {
  6.       for (y=0; y < len; y++) {
  7.          if (A[x] < A[y]) {
  8.             temp = A[x];
  9.             A[x] = A[y];
  10.             A[y] = temp;
  11.          }
  12.       }
  13.    }
  14.    return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment