if嵌套:
首先呢:
阅读程序:
else嵌套:
题目:
某商场优惠活动规定,某商品一次购买5件以(包含5件)10件以下(不包含10件)打9折,一次购买10件以上(包含十件)扫折。设计程序根据单件和客户的购买量计算总价。
代码:
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,x,y;
cin>>n>>x>>y;
if(y<0)
cout<<n;
else if(n<y/x)
cout<<0;
else if(y%x==0)
cout<<n-y/x;
else
cout<<n-(y/x+1);
return 0;
}
喜欢这篇文章的朋友可以关注我,在学习编程的路上,我们共同前进!