程序在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
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短