Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7. FILE *infile;
  8. int n,i,time,price,totPrice=0;
  9. infile=fopen("input.txt","r");
  10. if (infile==NULL) exit (1);
  11.  
  12. fscanf(infile,"%d",&n);
  13. for(i=0;i<n;i++)
  14. {
  15. fscanf(infile,"%d",&time);
  16.  
  17. if(time<=120)
  18. price=100;
  19. else
  20. price=100 + 5*(ceil((time-120)/10.0));
  21. totPrice+=price;
  22. }
  23. printf("%d\n",totPrice);
  24. fclose(infile);
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement