fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void)
  5. {
  6. int array[] = { 1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 7, 7, 7, 9, 10, -6, -7, -8, -9, -10 };
  7. int repetitions = 0;
  8.  
  9. int compare(const void* pa, const void* pb)
  10. {
  11. int a = *(int*)pa;
  12. int b = *(int*)pb;
  13. if (a == b)
  14. {
  15. repetitions = 1;
  16. return 0;
  17. }
  18. return a < b ? -1 : 1;
  19. }
  20.  
  21. qsort(array, sizeof(array) / sizeof(int), sizeof(int), compare);
  22. puts(repetitions ? "Yes!" : "No.");
  23. return 0;
  24. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:10:5: error: a function-definition is not allowed here before '{' token
     {
     ^
prog.cpp:24:1: error: expected '}' at end of input
 }
 ^
stdout
Standard output is empty