In-process conversion, Hangzhou electric 0j-2031

Source: Internet
Author: User

Conversion, Hangzhou Electric 0j-2031 original title address: http://acm.hdu.edu.cn/showproblem.php?pid=2031

"Problem Description" Enter a decimal number n and convert it to the R-binary output. The input data for "input" contains multiple test instances, each containing two integer n (32-bit integers) and R (2<=r<=16, r<>10). "Output" outputs the converted number for each test instance, with one row for each output. If R is greater than 10, then the corresponding number rules refer to 16 binary (for example, 10 is represented by a, and so on). "Sample Input" 7 2 23 12-4 3 "Sample Output" 111 1b-11 "AC Code"
1#include <stdio.h>2 voidPrintintnum)3 {4     if(num = =Ten) printf ("%c",'A');5     Else if(num = = One) printf ("%c",'B');6     Else if(num = = A) printf ("%c",'C');7     Else if(num = = -) printf ("%c",'D');8     Else if(num = = -) printf ("%c",'E');9     Else if(num = = the) printf ("%c",'F');Ten     Elseprintf"%d", num); One } A Main () - { -     intA, B, I, j, flag =0; the     intc[ -]; -      while(~SCANF ("%d%d", &a, &b)) -     { -         inti =0; +         if(b<2|| B> -|| b==Ten) Break; -         if(a<0) A =-A, flag =1; +          while(a) A         { atC[i] = a%b; -A = A/b; -i++; -         }         -         if(flag) printf ("-"), flag =0;  -          for(j=i-1; j>=0; j--) in print (c[j]); -printf"\ n"); to     } +}

In-process conversion, Hangzhou electric 0j-2031

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.