Advertisement
Guest User

Untitled

a guest
Mar 28th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include<stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void){
  5.  
  6. double pass = 0;
  7. int fail = 0;
  8. double counter = 0;
  9. int result = 0;
  10. double rate = 0;
  11.  
  12. while(result != -1){
  13. printf("Enter result(1=pass,2=fail,-1=end)");
  14. scanf("%d",&result);
  15. if(result==1){
  16. pass = pass + 1;
  17. }
  18. else{
  19. fail = fail + 1;
  20. }
  21. counter = counter + 1;
  22. }
  23.  
  24. printf("%d人通過%f人未通過",pass,fail);
  25.  
  26. rate = pass/counter;
  27. if(rate >= 0.8){
  28. puts("補習費漲價");
  29. }
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement