当前位置:网站首页>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 )
边栏推荐
- Appium inspector can directly locate the WebView page. Does anyone know the principle
- Feature extraction and detection 16 brisk feature detection and matching
- 6-2漏洞利用-ftp不可避免的问题
- [IVX junior engineer training course 10 papers to get certificates] 01 learn about IVX and complete the New Year greeting card
- The role of artificial intelligence in network security
- Circular statements in shell programming
- Datawhale community blackboard newspaper (issue 1)
- Study note 2 -- definition and value of high-precision map
- Basic concepts of machine learning
- Matlab uses audioread and sound to read and play WAV files
猜你喜欢
Docker installing Oracle_ 11g
Memorabilia of domestic database in June 2022
Single chip microcomputer -- hlk-w801 transplant NES simulator (III)
Feature extraction and detection 16 brisk feature detection and matching
Matlab uses audioread and sound to read and play WAV files
Datawhale community blackboard newspaper (issue 1)
[Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility
Convolutional neural network (including code and corresponding diagram)
Design and control of multi rotor aircraft (VII) -- sensor calibration and measurement model
Edge computing accelerates live video scenes: clearer, smoother, and more real-time
随机推荐
MATLAB realizes voice signal resampling and normalization, and plays the comparison effect
6-2 vulnerability exploitation - inevitable problems of FTP
I Brief introduction of radio energy transmission technology
Based on Simulink and FlightGear, the dynamic control of multi rotor UAV in equilibrium is modeled and simulated
About asp Net core uses a small detail of datetime date type parameter
[dynamic planning] interval dp:p3205 Chorus
What are the affordable Bluetooth headsets? Student party parity Bluetooth headset recommendation
Design and implementation of radio energy transmission system
2022年6月国产数据库大事记
关于ASP.NET CORE使用DateTime日期类型参数的一个小细节
No converter found for return value of type: class
ACM tutorial - quick sort (regular + tail recursion + random benchmark)
The concept and application of Cartland number
站在新的角度来看待产业互联网,并且去寻求产业互联网的正确方式和方法
How does schedulerx help users solve the problem of distributed task scheduling?
Docker安装Oracle_11g
Raspberry pie 4B learning notes - IO communication (1-wire)
Three core problems of concurrent programming
KS006基于SSM实现学生成绩管理系统
Convolutional neural network (including code and corresponding diagram)