is Hnnu 11654 big or small? "The 11th session of Hunan Province College students computer Program design Competition, Java large number comparison"

Source: Internet
Author: User




Original title Link: http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11654&courseid=0


A large number of comparisons, decisive use of Java, but also pay attention to the details.

Note: The comparison can not use equals, if used 0.0 and 0.00 is not equal, a bit like HDU2054, the problem has a detailed explanation

http://blog.csdn.net/hurmishine/article/details/51382141

AC Code:

Import Java.math.bigdecimal;import Java.util.scanner;public class Main {public static void main (string[] args) {int kase= 0; Scanner sc = new Scanner (system.in), while (Sc.hasnext ()) {BigDecimal a = Sc.nextbigdecimal (); BigDecimal B = sc.nextbigdecimal (); BigDecimal zero = new BigDecimal (0); System.out.printf ("Case%d:", ++kase); if (A.compareto (b) ==0) {System.out.println ("Same");} else if (A.compareto (b) >0) {System.out.println ("bigger");} Else{system.out.println ("Smaller");}}}


is Hnnu 11654 big or small? "The 11th session of Hunan Province College students computer Program design Competition, Java large number comparison"

Related Article

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.