当前位置:网站首页>【带你学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;
}
得分情况

边栏推荐
- A quick understanding of digital electricity
- leetcode2312. Selling wood blocks (difficult, weekly race)
- Ar Augmented Reality applicable scenarios
- leetcode2311. Longest binary subsequence less than or equal to K (medium, weekly)
- How to turn off debug information in rtl8189fs
- 剑指 Offer 31. 栈的压入、弹出序列
- "C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure Exercise 3
- Number of palindromes in C language (leetcode)
- No programming code technology! Four step easy flower store applet
- MySQL约束与多表查询实例分析
猜你喜欢

【OpenCV】-5种图像滤波的综合示例

Golang lock

How to use a product to promote "brand thrill"?

The concept, function, characteristics, creation and deletion of MySQL constraints

如何用一款产品推动「品牌的惊险一跃」?

leetcode2311. 小于等于 K 的最长二进制子序列(中等,周赛)

AR增强现实可应用的场景

Redis有序集合如何使用

1222. Password dropping (interval DP, bracket matching)

Selection of field types for creating tables in MySQL database
随机推荐
Architecture evolution from MVC to DDD
医药管理系统(大一下C语言课设)
WebGPU(一):基本概念
Niuke - Huawei question bank (51~60)
Decipher the AI black technology behind sports: figure skating action recognition, multi-mode video classification and wonderful clip editing
Spend a week painstakingly sorting out the interview questions and answers of high-frequency software testing / automated testing
2022 Q2 - 提昇技能的技巧總結
剑指 Offer II 031. 最近最少使用缓存
Failed to transform file 'xxx' to match attributes
MySQL constraints and multi table query example analysis
Construction and maintenance of business websites [13]
"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure Exercise 3
1218 square or round
mysql列转行函数指的是什么
There are spaces in the for loop variable in the shell -- IFS variable
STM32F103 - two circuit PWM control motor
Redis环境搭建和使用的方法
CSDN insertion directory in 1 second
剑指 Offer 47. 礼物的最大价值
OpenCASCADE7.6编译