- /*
- * 文件名称:
- * 作者: 钟新涌
- * 完成日期:2017 年 3 月 25 日
- * 版 本 号:v1.0
- * 对任务及求解方法的描述部分:
- * 输入描述:
- * 问题描述:
- * 程序输出:
- * 问题分析:
- *?算法设计:
- */
#include<iostream> using namespace std; int main() { int month,day,year; cout<<"请输入年份,月份:"<<endl; cin>>year>>month; if ((year%4==0&&year%100!=0)||year%400==0) { if(month==1||month==3||month==5||month==7||month==8||month==10||month==12) day=31; if(month==2) day=29; else day=30;} else { if(month==1||month==3||month==5||month==7||month==8||month==10||month==12) day=31; if(month==2) day=28; else day=30;} cout<<"天数为:"<<day<<endl; return 0; }
#include<iostream> using namespace std; void main() { int m,x; cout<<"欢迎使用利息计算器\n"; cout<<"请输入存款金额="; cin>>m; cout<<"==========存款期限===========\n"; cout<<"1、3个月\n"; cout<<"2、6个月\n"; cout<<"3、一年\n"; cout<<"4、两年\n"; cout<<"5、三年\n"; cout<<"6、五年\n"; cout<<"请输入存款期限代号:"; cin>>x; switch(x) { double a,z; case 1:a=m*0.031*0.25,z=m+a; cout<<"到期利息:"<<a<<"元,本息合计共:"<<z<<"元。"<<endl;break; case 2:a=m*0.033*0.5,z=m+a; cout<<"到期利息:"<<a<<"元,本息合计共:"<<z<<"元。"<<endl;break; case 3:a=m*0.035*1,z=m+a; cout<<"到期利息:"<<a<<"元,本息合计共:"<<z<<"元。"<<endl;break; case 4:a=m*0.044*2,z=m+a; cout<<"到期利息:"<<a<<"元,本息合计共:"<<z<<"元。"<<endl;break; case 5:a=m*0.05*3,z=m+a; cout<<"到期利息:"<<a<<"元,本息合计共:"<<z<<"元。"<<endl;break; case 6:a=m*0.055*5,z=m+a; cout<<"到期利息:"<<a<<"元,本息合计共:"<<z<<"元。"<<endl;break; default:cout<<"error\n"; } cout<<"感谢您的使用,欢迎下次光临!\n"; }
-
#include<iostream> #include<cmath> using namespace std; void main() { double x,y; cout<<"请输入x="; cin>>x; if(x<2) y=x; if(x>=2&&x<6) y=x*x+1; if(x>=6&&x<10) y=sqrt(x+1); if(x>=10) y=1/(x+1); cout<<"y="<<y<<endl; }
C++作业3
最新推荐文章于 2018-12-19 08:47:29 发布