fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. int cnt, sum, data, k, ht[5]={0};
  6. int m, n;
  7. cnt=0;
  8. do {
  9. scanf("%d", &data);
  10. cnt++;
  11. sum=0;
  12. n=data;
  13. for (m=0; m<=2; m++) {
  14. k=n%10;
  15. sum=sum+k;
  16. n=n/10;
  17. }
  18. k=sum%5;
  19. while (ht[k]!=0)
  20. k=(k+1)%5;
  21. ht[k]=data;
  22. } while (cnt<4);
  23. for (k=0; k<=4; k++)
  24. printf("ht[%d]=%d ", k, ht[k]);
  25. }
  26.  
Success #stdin #stdout 0s 9432KB
stdin
239
874
237
256
515
stdout
ht[0]=874 ht[1]=0 ht[2]=237 ht[3]=256 ht[4]=239