Programming, input a positive decimal integer, and then output its corresponding hexadecimal number, octal number

The new little knowledge learned by the original poster, I hope it will be useful to everyone!
Let's look at an example

#include<iostream>
using namespace std;
int main()
{
    
    
	int a;
	scanf("%d",&a);
	printf("%d  %x  %X  %o",a,a,a,a);
}

Looking at the effect,

it is obvious that %d %x %X %o corresponds to decimal, hexadecimal (represented by lowercase letters), hexadecimal (represented by uppercase letters), and octal;
remember these, you will encounter This kind of conversion between decimal, hexadecimal and octal is very easy to solve!
For example

#include<iostream>
using namespace std;
int main()
{
    
    
	int a;
	scanf("%x",&a);
	printf("%d  %x  %X  %o",a,a,a,a);
}


Big guys are welcome to advise, if you don’t understand the cute ones, you can send a private message to q2651877067. I’m very happy to answer you! ! ! QAQ

Guess you like

Origin blog.csdn.net/mmmjtt/article/details/114179897