global.cpp
来自「BigC++的源码」· C++ 代码 · 共 26 行
CPP
26 行
#include <iostream>
#include <cmath>
using namespace std;
double balance;
/**
Accumulates interest in the global variable balance
@param p the interest rate in percent
@param n the number of periods the investment is held
*/
void future_value(double p, int n)
{
balance = balance * pow(1 + p / 100, n);
}
int main()
{
balance = 10000;
future_value(5, 10);
cout << "After ten years, the balance is "
<< balance << "\n";
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?