当前位置:网站首页>Electronic Society C language level 1 32, calculate the power of 2
Electronic Society C language level 1 32, calculate the power of 2
2022-07-02 01:33:00 【dllglvzhenfeng】
Method 1 :
/*
Electronics Association C Language 1 level 32、 Calculation 2 The power of Method 1
Given a nonnegative integer n, seek 2n.
Input
An integer n.0 <= n < 31.
Output
An integer , namely 2 Of n Power .
The sample input
3
Sample output
8
*/
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n;
cin>>n;
cout<<pow(2,n);
return 0;
}
/*
12: Calculation 2 Of N Power
http://noi.openjudge.cn/ch0106/12/
2809: Calculation 2 Of N Power
http://bailian.openjudge.cn/practice/2809/
13: To calculate by power
http://noi.openjudge.cn/ch0105/13/
*/Method 2 :
/*
Electronics Association C Language 1 level 32、 Calculation 2 The power of Method 2
Given a nonnegative integer n, seek 2^n.
Input
An integer n.0 <= n < 31.
Output
An integer , namely 2 Of n Power .
The sample input
3
Sample output
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: Calculation 2 Of N Power
http://noi.openjudge.cn/ch0106/12/
2809: Calculation 2 Of N Power
http://bailian.openjudge.cn/practice/2809/
13: To calculate by power
http://noi.openjudge.cn/ch0105/13/
*/Links to related topics :
12: Calculation 2 Of N Power
OpenJudge - 12: Calculation 2 Of N Power
2809: Calculation 2 Of N Power
OpenJudge - 2809: Calculation 2 Of N Power
13: To calculate by power
OpenJudge - 13: To calculate by power
Ah C Language The first 1 Chapter Programming changes thinking ( The first 0 speak )
Ah C Language The first 2 Chapter Dream of direct flight ( The first 1-8 speak )
Ah C Language The first 3 Chapter The battle has just begun ( The first 9-15 speak )
Ah C Language The first 4 Chapter Heavyweights on stage ( The first 16-23 speak )
Ah C Language The first 5 Chapter The good play is behind ( The first 24-25 speak )
Ah C Language The first 6 Chapter Oh my god ! A string of numbers is approaching ( The first 26 speak )
Ah C Language The first 7 Chapter With it you can do more ( The first 27-28 speak )
Ah C Language The first 8 Chapter It's game time ( The first 29 speak )
边栏推荐
- 6-3漏洞利用-SSH环境搭建
- uTools
- 并发编程的三大核心问题
- Using tabbar in wechat applet
- Error creating bean with name ‘stringRedisTemplate‘ defined in class path re
- ACM教程 - 快速排序(常规 + 尾递归 + 随机基准数)
- uTools
- The role of artificial intelligence in network security
- 成功实现边缘编码需要了解的六大经验教训
- Finally got byte offer, 25-year-old inexperienced experience in software testing, to share with you
猜你喜欢

Since I understand the idea of dynamic planning, I have opened the door to a new world
![[WesternCTF2018]shrine writeup](/img/26/1700095c9b38b9b74a1b1136e5d5de.jpg)
[WesternCTF2018]shrine writeup

Based on Simulink and FlightGear, the dynamic control of multi rotor UAV in equilibrium is modeled and simulated

How can I batch produce the same title for the video?

企业应该选择无服务器计算吗?

Learning note 24 - multi sensor post fusion technology

Sql--- related transactions

Basic concepts of machine learning

Three core problems of concurrent programming

Recommend an online interface mock tool usemock
随机推荐
首场“移动云杯”空宣会,期待与开发者一起共创算网新世界!
学习笔记3--高精度地图关键技术(上)
How to compress video size while adding watermark with one click?
Error creating bean with name ‘stringRedisTemplate‘ defined in class path re
机器学习基本概念
Principle of finding combinatorial number and template code
Datawhale community blackboard newspaper (issue 1)
Should enterprises choose server free computing?
We should make clear the branch prediction
CTF daily question day45 sensor
No converter found for return value of type: class
How can I batch produce the same title for the video?
[WesternCTF2018]shrine writeup
Hcip day 14 (MPLS protocol)
MATLAB realizes voice signal resampling and normalization, and plays the comparison effect
Private project practice sharing [Yugong series] February 2022 U3D full stack class 009 unity object creation
关于ASP.NET CORE使用DateTime日期类型参数的一个小细节
matlab 使用 resample 完成重采样
Altium designer measure distance (ctrl+m)
GL Studio 5 installation and experience