C++第三次作业
来源:互联网 发布:生命起源知乎 编辑:程序博客网 时间:2024/04/26 11:32
一、本月有几天
#include <iostream>using namespace std;int main(){ int year,month; cout<<"请输入年份:"; cin>>year; cout<<"请输入月份:"; cin>>month; char tl; tl=(year%4==0&&year%100!=0)||(year%400==0); if(month==2) { if(tl==1) cout<<"本月有28天"; else cout<<"本月有29天"; } else if(month==1||month==3||month==5||month==7||month==8||month==10||month==12) { cout<<"本月有31天"; } else { cout<<"本月有30天"; } return 0;}二、定期存款利息计算器
#include<iostream>using namespace std;int main(){cout<<"欢迎使用利息计算器!"<<endl;cout<<"请输入存款金额:";int imoney,icount;double daccrual,drate,dterm,dfigure;//accrual:利息;figure:金额;rate:利率;term:存期cin>>imoney;cout<<"======存款期限======"<<endl;cout<<"1. 3个月\n2. 6个月\n3. 一年\n4. 两年\n5. 三年\n6. 五年"<<endl;cout<<"请输入存款期限的代号:";cin>>icount;switch(icount){case 1: dterm=0.25;drate=0.031;break;case 2: dterm=0.50;drate=0.033;break; case 3: dterm=1.00;drate=0.035;break;case 4: dterm=2.00;drate=0.044;break;case 5: dterm=3.00;drate=0.050;break;case 6: dterm=5.00;drate=0.055;break;default : cout<<"对不起,输入有误。"<<endl;}daccrual=imoney*dterm*drate;dfigure=imoney+daccrual;cout<<"到期利息为:"<<daccrual<<"元,"<<"本息合计共:"<<dfigure<<"元"<<endl;cout<<"感谢您的使用,欢迎下次光临!"<<endl;return 0;}三、多分数段函数求值
#include <iostream>#include <cmath>using namespace std;int main(){ double x,y; int figure; cout<<"请输入x的值:"; cin>>x; figure=(x<2)+(x<6)+(x<10); switch(figure) { case 0 : y=1/(x+1);break; case 1 : y=x;break; case 2 : y=x*x+1; break; case 3 : y=sqrt(x+1);break; default:cout<<"error\n";break; } cout<<"y="<<y; return 0;}
0 0
- c语言作业第三次
- 第三次c程序作业
- 第三次C语言程序设计作业
- C语言第三次作业
- 第三次C程序语言设计作业
- c语言程序设计第三次作业 2
- 第三次C程序课堂作业
- C语言第三次课堂作业
- 第三次c程序课后作业
- C语言程序设计第三次课堂作业
- C语言第三次作业练习
- 第三次作业
- 第三次作业
- 第三次作业
- 第三次作业
- 第三次作业
- 第三次作业
- 第三次作业
- Android_基础知识掌握
- bzoj3507【CQOI2014】通配符匹配
- 跟我一起学习MySQL技术内幕(第五版):(第二章学习日记4)
- Ubuntu环境下安装myeclipse
- Python def函数的定义、使用及参数传递实现代码
- C++第三次作业
- bzoj3170【TJOI2013】松鼠聚会
- 二分算法problem1001
- 切入业务日志
- LeetCode 160. Intersection of Two Linked Lists
- iOS 通知传值(顺传)
- bzoj2705【SDOI2012】Longge的问题
- ios pickerview选择城市
- Android ListView实现上拉到底部的时候自动刷新数据