fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int nominals[] = {25,10,5,1};
  5.  
  6. float fn;
  7. do {
  8. scanf("%f",&fn);
  9. } while(fn<0.0);
  10. int n = round(100*fn);
  11.  
  12. int s = 0;
  13. for(int *nominal=&nominals;nominal<nominals+(sizeof nominals/sizeof nominals[0]); ++nominal) {
  14. s += n / *nominal;
  15. n %= *nominal;
  16. }
  17.  
  18. printf("%d\n",s);
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 9432KB
stdin
-1
4.2
stdout
18