今天咱们学个难一点的循环结构:for循环,下面看一下例题

【题目描述】

给出一个整数1000000。

【输入】

一行,包含两个整数−1000000≤a≤1000000,1≤n≤10000。

【输出】

一个整数,即乘方结果。题目保证最终结果的绝对值不超过1000000。

【输入样例】

2 3

【输出样例】

8
#include<iostream>
#include<cstdio>
#include<cmath> //pow语句须调用cmath库
using namespace std;
int main()

{
  long long a,n,s;//定义三个整型变量a,n,s
   scanf("%lld %lld",&a,&n);//scanf输入a,n
   s=pow(a,n);//pow语句主要计算x的y次方,x,y及函数值都是double型
   printf("%lld",s);//printf输出s
   return 0;
}

 

相关文章:

  • 2021-08-12
  • 2021-12-25
  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2022-02-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2021-11-17
  • 2021-10-02
  • 2021-12-07
相关资源
相似解决方案