fork download
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. void QuickSort(A, p, r) {
  5. if(p < r) {
  6. int q = Partition(A, p, r)
  7. QuickSort(A, p, q - 1);
  8. QuickSort(A, q + 1, r);
  9. }
  10. }
  11.  
  12. int Partition(A, p, r) {
  13. int x = A[r];
  14. int i = p - 1;
  15. int j, aux;
  16. for(j = p; j < r - 1; j++) {
  17. if(A[j] <= x) {
  18. i = i + 1;
  19. aux = A[i];
  20. A[i] = A[j];
  21. A[j] = A[i];
  22. }
  23. }
  24. aux = A[i + 1];
  25. A[i + 1] = A[r];
  26. A[r] = aux;
  27. }
  28.  
  29. int main() {
  30. A[] = {2, 7, 5, 3, 1};
  31. QuickSort(A, 0, 4);
  32. return 0;
  33. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'QuickSort':
prog.c:6:3: warning: implicit declaration of function 'Partition' [-Wimplicit-function-declaration]
   int q = Partition(A, p, r)
   ^
prog.c:7:3: error: expected ',' or ';' before 'QuickSort'
   QuickSort(A, p, q - 1);
   ^
prog.c: In function 'Partition':
prog.c:13:11: error: subscripted value is neither array nor pointer nor vector
  int x = A[r];
           ^
prog.c:17:7: error: subscripted value is neither array nor pointer nor vector
   if(A[j] <= x) {
       ^
prog.c:19:11: error: subscripted value is neither array nor pointer nor vector
    aux = A[i];
           ^
prog.c:20:5: error: subscripted value is neither array nor pointer nor vector
    A[i] = A[j];
     ^
prog.c:20:12: error: subscripted value is neither array nor pointer nor vector
    A[i] = A[j];
            ^
prog.c:21:5: error: subscripted value is neither array nor pointer nor vector
    A[j] = A[i];
     ^
prog.c:21:12: error: subscripted value is neither array nor pointer nor vector
    A[j] = A[i];
            ^
prog.c:24:9: error: subscripted value is neither array nor pointer nor vector
  aux = A[i + 1];
         ^
prog.c:25:3: error: subscripted value is neither array nor pointer nor vector
  A[i + 1] = A[r];
   ^
prog.c:25:14: error: subscripted value is neither array nor pointer nor vector
  A[i + 1] = A[r];
              ^
prog.c:26:3: error: subscripted value is neither array nor pointer nor vector
  A[r] = aux;
   ^
prog.c: In function 'main':
prog.c:30:2: error: 'A' undeclared (first use in this function)
  A[] = {2, 7, 5, 3, 1};
  ^
prog.c:30:2: note: each undeclared identifier is reported only once for each function it appears in
prog.c:30:4: error: expected expression before ']' token
  A[] = {2, 7, 5, 3, 1};
    ^
prog.c: In function 'Partition':
prog.c:27:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
stdout
Standard output is empty