程序在C ++中查找2 ^ n的后两位数字
为此,我们将提供一个号码。我们的任务是计算并打印值2^n的最后两位,其中n是提供的数字。
示例
#include <bits/stdc++.h>
using namespace std;
//查找最后两位数字
int LastTwoDigit(long long int num){
int one = num % 10;
num /= 10;
int tens = num % 10;
tens *= 10;
num = tens + one;
return num;
}
int main(){
int n = 10;
long long int num = 1;
num = pow(2, n);
cout << "Last " << 2;
cout << " digits of " << 2;
cout << "^" << n << " = ";
cout << LastTwoDigit(num) << endl;
return 0;
}输出结果
Last 2 digits of 2^10 = 24
热门推荐
1 带狗狗训练
4 听力训练狗狗
6 怎训练狗狗
7 腹肌训练狗狗
8 网球训练狗狗
9 记叙文训练狗狗
10 狗狗太凶怎么训练
11 核心力量训练狗狗
12 狗狗乱叫怎么训练
13 发音训练狗狗
14 怎么训练狗狗叼东西给主人
15 荆州训练狗狗
16 篮球训练狗狗
17 做训练狗狗
18 训练狗狗坐姿