当前位置:网站首页>【带你学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;
}
得分情况
边栏推荐
- 正则表达式学习笔记
- leetcode2312. 卖木头块(困难,周赛)
- The concepts and differences between MySQL stored procedures and stored functions, as well as how to create them, the role of delimiter, the viewing, modification, deletion of stored procedures and fu
- 软件开发生命周期 --瀑布模型
- How to batch add background and transition effects to videos?
- 剑指 Offer 31. 栈的压入、弹出序列
- [technology development -21]: rapid overview of the application and development of network and communication technology -1- Internet Network Technology
- Sword finger offer 29 Print matrix clockwise
- What is AQS and its principle
- Failed to transform file 'xxx' to match attributes
猜你喜欢
leetcode373. Find and minimum k-pair numbers (medium)
How to use a product to promote "brand thrill"?
软件开发生命周期 --瀑布模型
pytest 测试框架
Five skills of adding audio codec to embedded system
Opencascade7.6 compilation
[graduation season] graduate seniors share how to make undergraduate more meaningful
如何用一款产品推动「品牌的惊险一跃」?
MySQL约束与多表查询实例分析
leetcode2311. Longest binary subsequence less than or equal to K (medium, weekly)
随机推荐
golang---锁
This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
[Video] Markov chain Monte Carlo method MCMC principle and R language implementation | data sharing
如何远程、在线调试app?
2022 Q2 - résumé des compétences pour améliorer les compétences
Email picture attachment
Openssl3.0 learning XXI provider encoder
A quick understanding of digital electricity
跨域?同源?一次搞懂什么是跨域
C language 3-7 daffodils (enhanced version)
leetcode2310. The one digit number is the sum of integers of K (medium, weekly)
Comparative analysis of MVC, MVP and MVVM, source code analysis
The concepts and differences between MySQL stored procedures and stored functions, as well as how to create them, the role of delimiter, the viewing, modification, deletion of stored procedures and fu
DNS domain name resolution
【LeetCode 43】236. The nearest common ancestor of binary tree
321. Chessboard segmentation (2D interval DP)
大厂裁员潮不断,双非本科出身的我却逆风翻盘挺进阿里
软件开发生命周期 --瀑布模型
[C #] use regular verification content
Software development life cycle -- waterfall model