当前位置:网站首页>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 )
边栏推荐
- 电子协会 C语言 1级 33 、奇偶数判断
- 遷移雲計算工作負載的四個基本策略
- Daily work and study notes
- 学习笔记3--高精度地图关键技术(上)
- error: . repo/manifests/: contains uncommitted changes
- Design and control of multi rotor aircraft (VII) -- sensor calibration and measurement model
- [IVX junior engineer training course 10 papers] 06 database and services
- Look at the industrial Internet from a new perspective and seek the correct ways and methods of industrial Internet
- 首场“移动云杯”空宣会,期待与开发者一起共创算网新世界!
- Since I understand the idea of dynamic planning, I have opened the door to a new world
猜你喜欢

Feature extraction and detection 16 brisk feature detection and matching

Android: how can golden nine and silver ten squeeze into the first-line big factories from small and medium-sized enterprises? The depth of interview questions in large factories

Matlab uses resample to complete resampling

Raspberry pie 4B learning notes - IO communication (1-wire)

Study note 2 -- definition and value of high-precision map

【疾病检测】基于BP神经网络实现肺癌检测系统含GUI界面

This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable

6-2漏洞利用-ftp不可避免的问题

What are the affordable Bluetooth headsets? Student party parity Bluetooth headset recommendation

Edge computing accelerates live video scenes: clearer, smoother, and more real-time
随机推荐
Unity AssetBundle subcontracting
Ubuntu20.04 PostgreSQL 14 installation configuration record
Learning notes 25 - multi sensor front fusion technology
人工智能在网络安全中的作用
matlab 使用 audioread 、 sound 读取和播放 wav 文件
Exclusive delivery of secret script move disassembly (the first time)
Design and implementation of radio energy transmission system
MySQL application day02
浅浅了解Servlet
Should enterprises choose server free computing?
Exclusive delivery of secret script move disassembly (the first time)
[IVX junior engineer training course 10 papers] 06 database and services
Since I understand the idea of dynamic planning, I have opened the door to a new world
Part 29 supplement (XXIX) basis of ECMAScript
This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
基于SSM实现微博系统
Day 13 of hcip (relevant contents of BGP agreement)
The role of artificial intelligence in network security
Principle of finding combinatorial number and template code
微信小程序中使用tabBar