1.5 13: Power calculation

Description
Given an integer a and a positive integer n, find the power an.

Enter a
line containing two integers a and n. -1000000 <= a <= 1000000, 1 <= n <= 10000.
Output
an integer, which is the result of the power. The title guarantees that the absolute value of the final result does not exceed 1,000,000.
Sample input
2 3
Sample output
8

#include <iostream>
using namespace std;
int main()
{
    
    
	int n,a,r=1;
	cin >>a>>n;
	for(int i=0;i<n;i++)
	{
    
    
		r*=a;
	}
	cout<<r<<endl;
	return 0;
}

Guess you like

Origin blog.csdn.net/yansuifeng1126/article/details/111994940