| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 483 人关注过本帖
标题:基础问题
取消只看楼主 加入收藏
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
快速回复:基础问题
数据加载中...
 
   



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

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