真的没骗你,这道才是简单题 —— 对任意给定的不超过 10 的正整数 n,要求你输出 2^n 。不难吧?
输入格式:
输入在一行中给出一个不超过 10 的正整数 n。
输出格式:
在一行中按照格式 2^n = 计算结果 输出 2 ^n 的值。
输入样例:
5
输出样例:
2^5 = 32
pow函数:
#include <stdio.h>
#include <math.h>
int main()
{
double x,t;
scanf("%lf",&x);
t=(int)pow(2,x);
printf("2^%.lf = %.lf",x,t);
return 0;
}
位运算:
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
cout << "2^" << n << " = " << (1 << n);
return 0;
}