程序在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
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短