求一个数的N次方
2015-08-31 01:55
246 查看
/* Enter 2 values for X and Y separated by space, The press <enter>: 2.4 4.85 2.4 to the power of 4.85 is = 69.8272 Enter 2 values for X and Y separated by space, The press <enter>: 3 4 3 to the power of 4 is = 81 */ #include <iostream> #include <cmath> double power(double x, int count); int main() { using std::cout; using std:: cin; double x , y; double p; cout << "Enter 2 values for X and Y separated by space, The press <enter>: "; cin >> x >> y; int tmp = y; if (y == tmp) p = power(x, tmp); else p = pow(x, y); cout << x << " to the power of " << y << " is = " << p << "\n"; return 0; } double power(double x, int count) { double p = 1; while (count) { p *= x; count--; } return p; }
相关文章推荐
- php大力力 [039节] 修改一下后台项目,同时启用印象笔记,要做的事情todo列表,记录在印象笔记,速度快一些
- Aptana Studio 3 切换中文版
- ubuntu14.04下JDK安装
- 一个实用的android框架(一)——架构
- 脚本安装zabbix2.4(#2.2),基于centos6.6 basic server
- c++访问数据库方法
- 关于521
- Java程序-进程中的"进程"
- 黑马程序员——GUI——GUI概述与使用
- [HDU 2571 命运]简单DP
- 引脚复用、CAN FIFO设置
- 原型模式
- How to Keep Different Versions of gcc ?
- 安卓音乐播放器
- Copy和MutableCopy
- 可能是最难围住的神经猫——寻找必胜路径的算法实现
- 记录一次MVC 3.0错误 HTTP 404您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用。请检查以下 URL 并确保其拼写正确。
- 欢迎使用CSDN-markdown编辑器
- C实现二叉树的先序遍历,中序遍历,后序遍历
- 博客搬家啦!