c++作业3

来源:互联网 发布:朝鲜第五次核试验知乎 编辑:程序博客网 时间:2024/05/21 07:58
#include<iostream>#include<cmath>using namespace std;int main(){    int x,y;cout<<"请输入x的值:";cin>>x;if(x>=10)y=1/(x+1);else if(6<=x&&x<10)y=sqrt(x+1);else if(2<=x&&x<6)y=x*x+1;else y=x;cout<<y<<endl;return 0;}
#include<iostream>using namespace std;int main(){int money,a,interest,sum=0;cout<<"欢迎使用利息计算器"<<"\n";cout<<"请输入存款金额:";cin>>money;cout<<"存款期限"<<"\n";cout<<"1.3个月"<<"\n"<<"2.6个月"<<"\n"<<"3.一年"<<"\n"<<"4.二年"<<"\n"<<"5.三年"<<"\n"<<"6.五年"<<"\n";    cout<<"请输入存款期限的代号:";    cin>>a;switch(a){case 1:interest=money*0.031*0.25;cout<<interest;break;case 2:interest=money*0.033*0.5;cout<<interest<<endl;break;    case 3:interest=money*0.035*1;cout<<interest<<endl;break;case 4:interest=money*0.044*2;    cout<<interest<<endl;break;case 5:interest=money*0.05*3;cout<<interest<<endl;break;case 6:interest=money*0.055*5;cout<<interest<<endl;break;}sum=money+interest;cout<<"到期利息为:"<<interest<<" 元,本息合计共"<<sum<<" 元."<<"\n";cout<<"感谢您的使用,欢迎下次光临\n";return 0; }
#include<iostream>using namespace std;int main(){int year,month;cout<<"请输入年份和月份:";cin>>year>>month;if(month==2){if((year%4==0)&&(year%100!=0)||(year%400==0))cout<<"本月有29天"<<endl;elsecout<<"本月有28天"<<endl;}else if(month==4||month==6||month==9||month==11)cout<<"本月有30天"<<endl;elsecout<<"本月有31天"<<endl;return 0;}

0 0
原创粉丝点击