fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int balance = 100, r = 12, years = 10;
  7. for (int i = 1; i <= years; i++) {
  8. balance = balance * (1 + r / 100.0);
  9. cout << "第" << i << "年 : " << balance << endl;
  10. }
  11.  
  12. return 0;
  13. }
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
第1年 : 112
第2年 : 125
第3年 : 140
第4年 : 156
第5年 : 174
第6年 : 194
第7年 : 217
第8年 : 243
第9年 : 272
第10年 : 304