当前位置:网站首页>电子协会 C语言 1级 32、计算2的幂
电子协会 C语言 1级 32、计算2的幂
2022-07-02 01:29:00 【dllglvzhenfeng】
方法一:
/*
电子协会 C语言 1级 32、计算2的幂 方法一
给定非负整数 n,求 2n。
输入
一个整数 n。0 <= n < 31。
输出
一个整数,即 2 的 n 次方。
样例输入
3
样例输出
8
*/
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n;
cin>>n;
cout<<pow(2,n);
return 0;
}
/*
12:计算2的N次方
http://noi.openjudge.cn/ch0106/12/
2809:计算2的N次方
http://bailian.openjudge.cn/practice/2809/
13:乘方计算
http://noi.openjudge.cn/ch0105/13/
*/方法二:
/*
电子协会 C语言 1级 32、计算2的幂 方法二
给定非负整数 n,求 2^n。
输入
一个整数 n。0 <= n < 31。
输出
一个整数,即 2 的 n 次方。
样例输入
3
样例输出
8
*/
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n,ans=1;
cin>>n;
for(int i=1;i<=n;i++)
{
ans*=2;
}
cout<<ans<<endl;
return 0;
}
/*
12:计算2的N次方
http://noi.openjudge.cn/ch0106/12/
2809:计算2的N次方
http://bailian.openjudge.cn/practice/2809/
13:乘方计算
http://noi.openjudge.cn/ch0105/13/
*/相关的题目的链接:
12:计算2的N次方
2809:计算2的N次方
13:乘方计算
啊哈C语言 第1章 编程改变思维(第0讲)
啊哈C语言 第1章 编程改变思维(第0讲)_dllglvzhenfeng的博客-CSDN博客
啊哈C语言 第2章 梦想直航(第1-8讲)
啊哈C语言 第2章 梦想直航(第1-8讲)_dllglvzhenfeng的博客-CSDN博客_啊哈c语言
啊哈C语言 第3章 较量才刚刚开始(第9-15讲)
啊哈C语言 第3章 较量才刚刚开始(第9-15讲)_dllglvzhenfeng的博客-CSDN博客
啊哈C语言 第4章 重量级选手登场(第16-23讲)
啊哈C语言 第4章 重量级选手登场(第16-23讲)_dllglvzhenfeng的博客-CSDN博客
啊哈C语言 第5章 好戏在后面(第24-25讲)
啊哈C语言 第5章 好戏在后面(第24-25讲)_dllglvzhenfeng的博客-CSDN博客
啊哈C语言 第6章 天啊!一大串数正在接近(第26讲)
啊哈C语言 第6章 天啊 一大串数正在接近(第26讲)_dllglvzhenfeng的博客-CSDN博客
啊哈C语言 第7章 有了它你能做更多的事(第27-28讲)
啊哈C语言 第7章 有了它你能做更多的事(第27-28讲)_dllglvzhenfeng的博客-CSDN博客
啊哈C语言 第8章 游戏时间到了(第29讲)
边栏推荐
- No converter found for return value of type: class
- Exclusive delivery of secret script move disassembly (the first time)
- uTools
- Bubble Sort Graph
- SAP ui5 beginner tutorial XXI - trial version of custom formatter of SAP ui5
- 8.8.4-PointersOnC-20220215
- 遷移雲計算工作負載的四個基本策略
- Android: the kotlin language uses grendao3, a cross platform app development framework
- Brief description of grafana of # yyds dry goods inventory # Prometheus
- [IVX junior engineer training course 10 papers] 04 canvas and a group photo of IVX and me
猜你喜欢
![[Floyd] post disaster reconstruction](/img/7a/f72c7781ef148212c870a56fb9a607.jpg)
[Floyd] post disaster reconstruction

Finally got byte offer, 25-year-old inexperienced experience in software testing, to share with you

微信小程序中使用tabBar

ACM tutorial - quick sort (regular + tail recursion + random benchmark)
![[disease detection] realize lung cancer detection system based on BP neural network, including GUI interface](/img/c9/3fe8693629a8452dcfdb4349ddee0d.png)
[disease detection] realize lung cancer detection system based on BP neural network, including GUI interface

Appium inspector can directly locate the WebView page. Does anyone know the principle

Hcip day 14 (MPLS protocol)

迁移云计算工作负载的四个基本策略

Principle of finding combinatorial number and template code

How does schedulerx help users solve the problem of distributed task scheduling?
随机推荐
[Floyd] post disaster reconstruction
Global and Chinese markets for the application of artificial intelligence in security, public security and national security 2022-2028: Research Report on technology, participants, trends, market size
uTools
Mathematics - feelings -20220215
How does schedulerx help users solve the problem of distributed task scheduling?
Just using the way and method of consuming the Internet to land and practice the industrial Internet will not bring long-term development
Datawhale 社区黑板报(第1期)
Finally got byte offer, 25-year-old inexperienced experience in software testing, to share with you
What is commercial endowment insurance? Is commercial endowment insurance safe?
Since I understand the idea of dynamic planning, I have opened the door to a new world
Tencent cloud techo youth dream campus trip into Wuhan University
遷移雲計算工作負載的四個基本策略
Brief introduction to the development of mobile network
[IVX junior engineer training course 10 papers] 04 canvas and a group photo of IVX and me
I Brief introduction of radio energy transmission technology
[IVX junior engineer training course 10 papers to get certificates] 09 chat room production
关于ASP.NET CORE使用DateTime日期类型参数的一个小细节
Global and Chinese market of avionics systems 2022-2028: Research Report on technology, participants, trends, market size and share
微信小程序中使用tabBar
成功实现边缘编码需要了解的六大经验教训