当前位置:网站首页>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 )
边栏推荐
- Learning note 3 -- Key Technologies of high-precision map (Part 1)
- ES6 new method of string
- [dynamic planning] interval dp:p3205 Chorus
- 学习笔记3--高精度地图关键技术(上)
- Convolutional neural network (including code and corresponding diagram)
- 学习笔记25--多传感器前融合技术
- ECS project deployment
- [Maya] the error of importing Maya into Metahuman
- 并发编程的三大核心问题
- Learning note 24 - multi sensor post fusion technology
猜你喜欢

Four basic strategies for migrating cloud computing workloads

学习笔记24--多传感器后融合技术

Android high frequency network interview topic must know and be able to compare Android development environment

Matlab uses resample to complete resampling

Design and control of multi rotor aircraft (VII) -- sensor calibration and measurement model

Leetcode, 3 repeatless longest subsequence

II Basic structure of radio energy transmission system

Introduction to ffmpeg Lib

Using tabbar in wechat applet

现货黄金分析的技巧有什么呢?
随机推荐
matlab 使用 resample 完成重采样
TSINGSEE青犀平台如何实现同一节点同时播放多个视频?
What is commercial endowment insurance? Is commercial endowment insurance safe?
NeRV: Neural Reflectance and Visibility Fields for Relighting and View Synthesis
只是以消费互联网的方式和方法来落地和实践产业互联网,并不能够带来长久的发展
[image enhancement] vascular image enhancement based on frangi filter with matlab code
开发那些事儿:如何利用Go单例模式保障流媒体高并发的安全性?
Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage
Android: the kotlin language uses grendao3, a cross platform app development framework
并发编程的三大核心问题
遊戲思考15:全區全服和分區分服的思考
Another programmer "deleted the library and ran away", deleted the code of the retail platform, and was sentenced to 10 months
Exclusive delivery of secret script move disassembly (the first time)
Learning notes 25 - multi sensor front fusion technology
Shell Function
人工智能在网络安全中的作用
Feature extraction and detection 16 brisk feature detection and matching
Fastadmin controls the length of fields in the table
GL Studio 5 installation and experience
Variables and constants of go language foundation