-
Notifications
You must be signed in to change notification settings - Fork 0
/
ada_lab_2.cpp
59 lines (58 loc) · 1.04 KB
/
ada_lab_2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>
using namespace std;
bool palindrone(string &str, int s, int e)
{
if (s == e)
{
return true;
}
if (str[s] != str[e])
{
return false;
}
if (s < e + 1)
{
return palindrone(str, s + 1, e - 1);
}
return true;
}
int exponent(int base, int exponent)
{
int ans = 1;
if (exponent == 0)
{
return 1;
}
else
{
while (exponent > 0)
{
if (exponent & 1)
{
ans *= base;
}
exponent >>= 1;
base *= base;
}
return ans;
}
}
int main()
{
// string s;
// cin >> s;
// if (palindrone(s, 0, s.length() - 1) == true)
// {
// cout << s << " "
// << "is a palindrone\n";
// }
// else
// {
// cout << s << " "
// << "is not a palindrone\n";
// }
int b, e;
cin >> b >> e;
cout << exponent(b, e);
return 0;
}