Direct Sticker Code
#include"stdio.h"intMain () {intNum, NUM1, r, n =0; Chardtor[ +]; printf ("Please enter the number to convert:"); scanf ("%d",&NUM1); Num=NUM1; printf ("number to convert to binary (2~16)"); scanf ("%d",&R); Do { if(num% r >=Ten) Dtor[n]= num%r+ -; ElseDtor[n]= num%r+ -; Num= num/R; if(num = =0) Break; N++; } while(1); printf ("decimal number%d and%d binary numbers", Num1,r); for(; n >=0; n--) printf ("%c", Dtor[n]); printf ("equivalent");}
Hexadecimal number Addition
#include <stdio.h>intMain () {__int64 A, B; //because the defined number has a maximum length of 16 bits, it is defined as int64 while(SCANF ("%i64x%i64x", &a,&b)! =EOF) printf (a+b>=0?"%i64x\n":"-%i64x\n",a+b>0? a+b:-a-b);//It is the perfect application of the three-mesh operator to examine the output format of the problem. return 0;}
Convert binary, hexadecimal number added