当前位置:网站首页>C Primer Plus Chapter 9 question 10 binary conversion
C Primer Plus Chapter 9 question 10 binary conversion
2022-07-05 23:00:00 【multydoffer】
Write a to_base_n() Accept functions in two 2-10 Parameters in range , Then take the second 1 Hexadecimal print specified in parameter No 2 Number of parameters . for example ,to_base_n(129,8) The result is 201, That is to say 129 The octal number of . Test the function in a complete program .
Here is the code :
#include <stdio.h>
void to_base_n(int n, int x);
int main(void)
{
int n, x;
printf("Enter a number and the base for the form of prints.\n");
printf("Now enter the number in the demical system: ");
scanf("%d", &x);
printf("Enter the base of it(2-10): ");
scanf("%d", &n);
while(n < 2 && n > 10)
{
printf("Enter the base(2-10): ");
scanf("%d", &n);
}
to_base_n(n, x);
return 0;
}
void to_base_n(int n, int x)
{
if(x < 0)
{
x *= -1;
printf("-");
}
if(x > 0)
{
to_base_n(n, x / n);
printf("%d", x % n);
}
return;
}
边栏推荐
- 谷歌地图案例
- 从 1.5 开始搭建一个微服务框架——日志追踪 traceId
- [speech processing] speech signal denoising based on Matlab GUI Hanning window fir notch filter [including Matlab source code 1711]
- 从 1.5 开始搭建一个微服务框架——日志追踪 traceId
- openresty ngx_ Lua request response
- 查看网页最后修改时间方法以及原理简介
- Tiktok__ ac_ signature
- All expansion and collapse of a-tree
- MCU case -int0 and INT1 interrupt count
- 南京:全面启用商品房买卖电子合同
猜你喜欢

Three. Js-01 getting started

Three. JS VR house viewing

查看网页最后修改时间方法以及原理简介

Paddy serving v0.9.0 heavy release multi machine multi card distributed reasoning framework

基于STM32的ADC采样序列频谱分析

Data type, variable declaration, global variable and i/o mapping of PLC programming basis (CoDeSys)

Yiwen gets rid of the garbage collector

【无标题】
![[digital signal denoising] improved wavelet modulus maxima digital signal denoising based on MATLAB [including Matlab source code 1710]](/img/b4/af689abb3ad4e25988f2d17152406e.jpg)
[digital signal denoising] improved wavelet modulus maxima digital signal denoising based on MATLAB [including Matlab source code 1710]
![[secretly kill little buddy pytorch20 days] - [Day2] - [example of picture data modeling process]](/img/41/4de83d2c81b9e3485d503758e12108.jpg)
[secretly kill little buddy pytorch20 days] - [Day2] - [example of picture data modeling process]
随机推荐
[digital signal denoising] improved wavelet modulus maxima digital signal denoising based on MATLAB [including Matlab source code 1710]
Function default parameters, function placeholder parameters, function overloading and precautions
我把开源项目alinesno-cloud-service关闭了
一文搞定class的微觀結構和指令
鏈錶之雙指針(快慢指針,先後指針,首尾指針)
Starting from 1.5, build a micro Service Framework -- log tracking traceid
d3dx9_ What if 29.dll is missing? System missing d3dx9_ Solution of 29.dll file
Unity Max and min constraint adjustment
Exponential weighted average and its deviation elimination
分布式解决方案之TCC
Binary tree (II) -- code implementation of heap
Openresty ngx Lua regular expression
Arduino measures AC current
如何快速理解复杂业务,系统思考问题?
我对新中台模型的一些经验思考总结
2022.02.13 - SX10-30. Home raiding II
Masked Autoencoders Are Scalable Vision Learners (MAE)
[speech processing] speech signal denoising based on Matlab GUI Hanning window fir notch filter [including Matlab source code 1711]
一文搞定JVM的内存结构
All expansion and collapse of a-tree