当前位置:网站首页>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;
}
边栏推荐
- [speech processing] speech signal denoising and denoising based on MATLAB low-pass filter [including Matlab source code 1709]
- Hcip day 12 (BGP black hole, anti ring, configuration)
- Common model making instructions
- How can easycvr cluster deployment solve the massive video access and concurrency requirements in the project?
- 【无标题】
- Getting started stm32--gpio (running lantern) (nanny level)
- [screen recording] how to record in the OBS area
- Request preview display of binary data and Base64 format data
- H5c3 advanced - player
- Metasploit(msf)利用ms17_010(永恒之蓝)出现Encoding::UndefinedConversionError问题
猜你喜欢

谷歌地图案例

TCC of distributed solutions

Metasploit(msf)利用ms17_010(永恒之蓝)出现Encoding::UndefinedConversionError问题

Leetcode weekly The 280 game of the week is still difficult for the special game of the week's beauty team ~ simple simulation + hash parity count + sorting simulation traversal

All expansion and collapse of a-tree

Registration and skills of hoisting machinery command examination in 2022

2022.02.13 - SX10-30. Home raiding II

Thoroughly understand JVM class loading subsystem

Google Maps case

Arduino measures AC current
随机推荐
[untitled]
Google Maps case
东南亚电商指南,卖家如何布局东南亚市场?
Composition of interface
One article deals with the microstructure and instructions of class
如何快速理解复杂业务,系统思考问题?
Three. Js-01 getting started
[secretly kill little buddy pytorch20 days] - [Day2] - [example of picture data modeling process]
Selenium+Pytest自动化测试框架实战
Methods modified by static
Starting from 1.5, build a micro Service Framework -- log tracking traceid
Data type, variable declaration, global variable and i/o mapping of PLC programming basis (CoDeSys)
查看网页最后修改时间方法以及原理简介
利用LNMP实现wordpress站点搭建
Commonly used probability distributions: Bernoulli distribution, binomial distribution, polynomial distribution, Gaussian distribution, exponential distribution, Laplace distribution and Dirac delta d
Distributed resource management and task scheduling framework yarn
Ultrasonic sensor flash | LEGO eV3 Teaching
Thoroughly understand JVM class loading subsystem
Starting from 1.5, build a micro Service Framework -- log tracking traceid
Codeforces Global Round 19