新手光能
#include<iostream>
using namespace std;
long long n,a,b,cnt;
int main(){
cin>>n;
if(n<10000){
a=n/25;
b=0;
cnt+=n-a*25-b;
}else if(n<100000){
a=n/100*30/25;
b=n/100*70/40;
cnt+=n-a*25-b*40;
}else {
a=n/2/25;
b=n/2/40;
cnt+=n-a*25-b*40;
}
cout<<a<<" "<<b<<endl<<cnt;
return 0;
}
初级光能
int a,b=0,c=0;
cin>>a;
if(a<10000){
b=a/25;
cout<<b<<" "<<c<<endl<<a%25;
}
else if(a<100000){
b=a*0.3/25;
c=a*0.7/40;
cout<<b<<" "<<c<<endl<<a-b*25-c*40;
}
else{
b=a*0.5/25;
c=a*0.5/40;
cout<<b<<" "<<c<<endl<<a-b*25-c*40;
}
核心
给你拆分一下
1.如果捐款小于一万元,则购买文学类书籍
if(a<10000){
b=a/25;
cout<<b<<" "<<c<<endl<<a%25;
}
2.如果捐款不小于一万元且小于十万元,则30%用于购买文学类书籍,70%用于购买工具书
else if(a<100000){
b=a*0.3/25;//a的30%=a*0.3
c=a*0.7/40;//a的70%=a*0.7
cout<<b<<" "<<c<<endl<<a-b*25-c*40;
}
3.如果捐款不小于十万元,则50%用于购买文学类书籍,50%用于购买工具书
else{
b=a*0.5/25;//a的50%=a*0.5
c=a*0.5/40;//同上
cout<<b<<" "<<c<<endl<<a-b*25-c*40;
}
望采纳