标题:基础问题
取消只看楼主
nala
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2006-9-2
 问题点数:0 回复次数:0 
基础问题

#include <iostream>

using std::cin;
using std::cout;
using std::endl;
using std::ios;
using std::fixed;

#include <iomanip>
using std::setw;
using std::setprecision;

#include <cmath>// using pow in maths

int main()
{
double amount;//amount on deposit
double princible = 1000.0;//starting princible
double rate = 0.1;//record rate

//out put table column heads
cout << " YEAR " << setw(21) << " Amount on deposit " << endl;
cout << fixed << setprecision(2);//这句话到底起到什么作用,它又是怎么起作用的呢~?

//calculate
for( int year = 1; year <= 10; year++ ){
amount = princible*pow(1.0 + rate,year);

//output table row
cout << setw(4) << year
<< setw(21) << amount << endl;
}//end for

return 0;//indicate successful termination
}//end function main

搜索更多相关主题的帖子: 基础 
2006-09-13 08:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-89809-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.093832 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved