C++中如何输入次幂

来源:百度知道 编辑:UC知道 时间:2024/09/20 19:38:02
最好写上:怎样写头文件
pow(10,5)是什么意思,-1的i次幂怎么写

C++中输入次幂,计算实现方法如下:

// First.cpp : Defines the entry point for the console application.  

//  

  

#include "stdafx.h"  

#include "iostream.h"  

int main(int argc, char* argv[])  

{  

    

    int value=2;  

    int pow=10;  

    int res=1;  

    cout<<value<<"的"<<pow<<"次幂是:"<<endl;  

    for(int cnt=1;cnt<=pow;++cnt)  

        res=res*value;  

  

    cout<<res<<endl;  

 &nbs