fork download
  1. #include <stdio.h>
  2. void * studentsCount(int *Arr, int len, int score, int *lessCount, int *moreCount);
  3. int main(void) {
  4. // your code goes here
  5. int Arr[5]={10,20,30,40,50};
  6. int lessCount,moreCount;
  7. studentsCount(Arr,5,30, &lessCount, &moreCount);
  8. return 0;
  9. }
  10. void * studentsCount(int *Arr, int len, int score, int *lessCount, int *moreCount) {
  11. int l = 0;int u = 0,n=0;
  12. if (Arr == NULL||len<=0||score<=0)
  13. return NULL;
  14. for (int i = 0; i < len; i++)
  15. { if(Arr[i]==score)
  16. { n++;
  17. if(n==len)
  18. {l=0;u=0;}}
  19.  
  20. else if (Arr[i] < score)
  21. l++;
  22. else
  23. u++;
  24. }
  25. *lessCount=l;*moreCount=u;
  26.  
  27. printf("\n%d\n %d",*lessCount,*moreCount);
  28.  
  29. }
  30.  
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
2
 2