【c++ primer 5th 练习3.43】教程文章相关的互联网学习教程文章

C++编程练习——计算利息【代码】

#include<iostream> using namespace std;int main() {double intrest, total, min;int start, loan;cout << "如果你想要开始计算你的到期利息、总应付款和最小付款额,请输入1\n";cin >> start;while (start==1){cout << "请输入你的借贷金额:\n";cin >> loan;if (loan <= 1000)intrest = loan*0.015;elseintrest = 15 + (loan - 1000)*0.01;total = loan + intrest;if (total <= 10)min = total;else if (total <= 100)min = 10...

C++Primer Plus笔记——第十四章 C++中的代码重用课后编程练习答案

编程练习答案 习题1 习题2 习题3 习题4 习题5 习题1//winec.h #ifndef WINEC_H_ #define WINEC_H_ #include <iostream> #include <string> #include <valarray> using namespace std; template<class T1, class T2> class Pair { private:T1 year;T2 bottles; public:Pair(const T1 &yr, const T2 &bt) :year(yr), bottles(bt) {}Pair() {}void Set(const T1 &yr, const T2 &bt);int Sum()const;void Show(int y)con...

C++编程练习——一个简单的石头剪刀布游戏【代码】

#include<iostream> using namespace std;int main() {char player1, player2;int start;cout << "这是一个石头剪刀布的游戏,如果你想开始游戏,请输入1,否则输入0\n";cin >> start;while (start){cin >> player1 >> player2;if (player1 == player2)cout << "平局\n";else if (player1 == 'R' && player2 == 'S')cout << "player1获胜!\n";else if (player1 == 'S' && player2 == 'P')cout << "player1获胜!\n";else if (playe...