Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int amount = 0;
- printf("請輸入訂單金額:");
- scanf("%d", &amount);
- //
- double discount = 0.0;
- if(amount>0 && amount<=1000){
- discount = 1.0;
- } else if(amount>1000 && amount<=2000){
- discount = 0.95;
- } else if(amount>2000 && amount<=3000){
- discount = 0.9;
- } else if(amount>3000 && amount<=5000){
- discount = 0.85;
- } else { //????
- discount = 0.8;
- }
- //
- amount *= discount; //amount = amount*discount;
- printf("折扣後價格=%d\n", amount);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement