fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. int x;
  6. int cnt=0;
  7. int sum=0;
  8. scanf("%d",&x);
  9. while(x!=-1) {
  10. sum+=x;
  11. cnt++;
  12. scanf("%d",&x);
  13. }
  14. printf("%d",sum/cnt);
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 5540KB
stdin
2 3 4 -1
stdout
3