当前位置:网站首页>【带你学c带你飞】4day第2章 用C语言编写程序(练习 2.5 生成乘方表与阶乘表
【带你学c带你飞】4day第2章 用C语言编写程序(练习 2.5 生成乘方表与阶乘表
2022-07-02 02:11:00 【尽力漂亮】
知识点
pow(2,i)函数
练习 R7-1 生成2的乘方表
输入一个非负整数n,生成一张2的乘方表,输出20~2n的值。可调用幂函数计算2的乘方。
输入格式:
输入在一行中给出一个非负整数n。
输出格式:
按照幂的递增顺序输出n+1行,每行格式为“pow(2,i) = 2的i次幂的值”,请注意等号的左右各有一个空格。题目保证计算结果不超过整数的取值范围。
输入样例:
3
输出样例:
pow(2,0) = 1
pow(2,1) = 2
pow(2,2) = 4
pow(2,3) = 8
demo
#include <stdio.h>
#include <math.h>
int main()
{
int i,n;
int p;
scanf("%d",&n);
for(i=0;i<=n;i++){
p=pow(2,i);
printf("pow(2,%d) = %d\n",i,p);
}
return 0;
}
得分情况
边栏推荐
- Webgpu (I): basic concepts
- "C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure
- How to debug apps remotely and online?
- Construction and maintenance of business websites [11]
- Email picture attachment
- Failed to transform file 'xxx' to match attributes
- Regular expression learning notes
- JMeter (I) - download, installation and plug-in management
- Spend a week painstakingly sorting out the interview questions and answers of high-frequency software testing / automated testing
- STM32F103 - two circuit PWM control motor
猜你喜欢
What style of Bluetooth headset is easy to use? High quality Bluetooth headset ranking
How to debug apps remotely and online?
Sword finger offer 62 The last remaining number in the circle
Word search applet design report based on cloud development +ppt+ project source code + demonstration video
MySQL约束与多表查询实例分析
MySQL主从延迟问题怎么解决
如何远程、在线调试app?
[Video] Markov chain Monte Carlo method MCMC principle and R language implementation | data sharing
Leetcode face T10 (1-9) array, ByteDance interview sharing
Opengauss database backup and recovery guide
随机推荐
Based on configured schedule, the given trigger will never fire
Webgpu (I): basic concepts
Iterative unified writing method of binary tree
What is the MySQL column to row function
321. Chessboard segmentation (2D interval DP)
如何用一款产品推动「品牌的惊险一跃」?
np.where 和 torch.where 用法
STM32F103——两路PWM控制电机
1218 square or round
734. Energy stone (greed, backpack)
What is AQS and its principle
1222. Password dropping (interval DP, bracket matching)
MySQL主从延迟问题怎么解决
This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
How to execute an SQL in MySQL
MySQL约束与多表查询实例分析
New news, Wuhan Yangluo international port, filled with black technology, refreshes your understanding of the port
MySQL中一条SQL是怎么执行的
【毕业季】研究生学长分享怎样让本科更有意义
医药管理系统(大一下C语言课设)