真的没骗你,这道才是简单题 —— 对任意给定的不超过10的正整数n,要求你输出2n。不难吧?
输入格式:
输入在一行中给出一个不超过10的正整数n。
输出格式:
在一行中按照格式 2^n = 计算结果
输出2n的值。
输入样例:
5
输出样例:
2^5 = 32
水题
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> using namespace std; int main() { int n,t; cin>>n;t=n; int ans=1; while(t--) { ans<<=1; } cout<<"2^"<<n<<" = "<<ans; return 0; }