美文网首页
ZZULIOJ1028: I love 闰年!

ZZULIOJ1028: I love 闰年!

作者: 是公主啊 | 来源:发表于2022-03-09 11:40 被阅读0次

判断闰年

//I LOVE 闰年
#include<iostream>
using namespace std;
int main(){
    int x;
    cin>>x;
    if((x%4==0&&x%100!=0)||(x%400==0)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
} 

tips

判断闰年的方法:被4整除但不被100整除,或者被400整除

员工薪水

//员工薪水
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int x;
    float salary;
    cin>>x;
    if(x<=10000){
        salary=1500+x*0.05;
        cout<<fixed<<setprecision(2)<<salary<<endl;
    }else if(x>10000&&x<=50000){
        salary=1500+10000*0.05+(x-10000)*0.03;
        cout<<fixed<<setprecision(2)<<salary<<endl;
    }else if(x>50000){
        salary=1500+10000*0.05+40000*0.03+(x-50000)*0.02;
        cout<<fixed<<setprecision(2)<<salary<<endl;
    }
    return 0;
} 

注意中间段也要算上

相关文章

网友评论

      本文标题:ZZULIOJ1028: I love 闰年!

      本文链接:https://www.haomeiwen.com/subject/qadtdrtx.html