Guest User

Untitled

a guest
Feb 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2. int main() {
  3. float price;
  4. printf("請輸入價格:");
  5. scanf("%f", &price);
  6. float d;
  7. if(price>0 && price<=1000){
  8. d=1.0;
  9. } else if(price>1000 && price<=2000){
  10. d=0.9;
  11. } else if(price>2000 && price<=5000){
  12. d=0.85;
  13. } else if(price>5000){
  14. d=0.8;
  15. } else{
  16. printf("錯誤!\n");
  17. d=0.0;
  18. }
  19. price*=d;
  20. printf("折扣後價格為%d\n",(int)price);
  21. return 0;
  22. }
Add Comment
Please, Sign In to add comment