fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int compare(const void *a, const void *b)
  5. {
  6. int *x = (int*)a;
  7. int *y = (int*)b;
  8. return *x - *y;
  9. }
  10.  
  11. int main()
  12. {
  13. int *num,n,t;
  14. int sum = 0;
  15. scanf("%d %d",&n,&t);
  16. num = (int*)malloc(sizeof(int) * n);
  17. int i;
  18. for(i=0;i<n;i++)
  19. scanf("%d",&num[i]);
  20. qsort(num,n,sizeof(int),compare);
  21. n -= 1;
  22. while(n >= 0){
  23. sum += num[n];
  24. n -= k;
  25. }
  26. printf("%d\n",sum);
  27. retunr 0;
  28. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
5 3
6
1
2
8
7
compilation info
prog.c: In function ‘main’:
prog.c:24: error: ‘k’ undeclared (first use in this function)
prog.c:24: error: (Each undeclared identifier is reported only once
prog.c:24: error: for each function it appears in.)
prog.c:27: error: ‘retunr’ undeclared (first use in this function)
prog.c:27: error: expected ‘;’ before numeric constant
prog.c:15: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
prog.c:19: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
stdout
Standard output is empty