Waterloo Cup basic practice--Decimal turn hexadecimal __ Waterloo Cup practice

Source: Internet
Author: User
Problem description The hexadecimal number is a representation of an integer that is often used in programming. It has a 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f total of 16 symbols, representing 0 to 15 of the decimal number, respectively. The hexadecimal counting method is full 16 into 1, so the decimal 16 is 10 in hexadecimal, and the decimal 17 is 11 in hexadecimal, and so on, and the decimal 30 in hexadecimal is 1 E.
Gives a nonnegative integer, which is expressed as a 16-in form. The input format input contains a non-negative integer A that represents the number to convert. 0<=a<=2147483647 output format output of this integer in the 16-example Input 30 sample output 1E

Import Java.util.Scanner;
public class Main {public
    static void Main (string[] args) {
        Scanner in = new Scanner (system.in);
        Integer n = in.nextint ();
        In.close ();
        System.out.println (integer.tohexstring (n). toUpperCase ());
    }
About the conversion, I do not like this problem, I feel that there is not much significance (but 16 into the octal or more troublesome, there will be the problem), here in the code lazy, Java with the conversion function, so directly written. There is also a sort of problem, I do not intend to write out, because that question is also directly call the Arrays.sort () function, there is no technical content

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.