当前位置:网站首页>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 )
边栏推荐
- 现货黄金分析的技巧有什么呢?
- The first "mobile cloud Cup" empty publicity meeting, looking forward to working with developers to create a new world of computing!
- [IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games
- How can I batch produce the same title for the video?
- Shell Function
- [IVX junior engineer training course 10 papers] 05 canvas and aircraft war game production
- Based on Simulink and FlightGear, the dynamic control of multi rotor UAV in equilibrium is modeled and simulated
- [IVX junior engineer training course 10 papers to get certificates] 0708 news page production
- 机器学习基本概念
- Penser au jeu 15: penser au service complet et au sous - service
猜你喜欢
What are the affordable Bluetooth headsets? Student party parity Bluetooth headset recommendation
人工智能在网络安全中的作用
Infiltration records of CFS shooting range in the fourth phase of the western regions' Dadu Mansion
迁移云计算工作负载的四个基本策略
6-3 vulnerability exploitation SSH environment construction
6-2 vulnerability exploitation - inevitable problems of FTP
Edge computing accelerates live video scenes: clearer, smoother, and more real-time
Game thinking 15: thinking about the whole region and sub region Services
Feature extraction and detection 16 brisk feature detection and matching
[Floyd] post disaster reconstruction
随机推荐
机器学习基本概念
SAP ui5 beginner tutorial 20 - explanation of expression binding usage of SAP ui5
人工智能在网络安全中的作用
首场“移动云杯”空宣会,期待与开发者一起共创算网新世界!
Circular statements in shell programming
基于SSM实现微博系统
Learning note 3 -- Key Technologies of high-precision map (Part 1)
Since I understand the idea of dynamic planning, I have opened the door to a new world
[IVX junior engineer training course 10 papers to get certificates] 01 learn about IVX and complete the New Year greeting card
Android: the kotlin language uses grendao3, a cross platform app development framework
电子协会 C语言 1级 32、计算2的幂
This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
站在新的角度来看待产业互联网,并且去寻求产业互联网的正确方式和方法
The author is more willing to regard industrial Internet as a concept much richer than consumer Internet
并发编程的三大核心问题
Day 13 of hcip (relevant contents of BGP agreement)
How can the tsingsee Qingxi platform play multiple videos at the same time on the same node?
电子协会 C语言 1级 33 、奇偶数判断
Android high frequency network interview topic must know and be able to compare Android development environment
6-2 vulnerability exploitation - inevitable problems of FTP