zoukankan      html  css  js  c++  java
  • [PAT] 1001 A+B Format (20 分)Java

    1001 A+B Format (20 分)

    Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).

    Input Specification:

    Each input file contains one test case. Each case contains a pair of integers a and b where 106​​a,b106​​. The numbers are separated by a space.

    Output Specification:

    For each test case, you should output the sum of a and b in one line. The sum must be written in the standard format.

    Sample Input:

    -1000000 9
    

    Sample Output:

    -999,991


    代码示例:

     1 import java.util.Scanner;
     2 /**
     3  * @Auther: Xingzheng Wang
     4  * @Date: 2019/1/17 10:06
     5  * @Description: pattest
     6  * @Version: 1.0
     7  */
     8 public class PAT1001 {
     9     public static void main(String[] args){
    10         Scanner sc = new Scanner(System.in);
    11         int a = sc.nextInt();
    12         int b = sc.nextInt();
    13         System.out.printf("%,d",a+b);
    14     }
    15 }
     




  • 相关阅读:
    Zookeeper 系列(一)基本概念
    深入浅出 JMS(三)
    深入浅出 JMS(四)
    深入浅出 JMS(三)
    深入浅出 JMS(二)
    深入浅出 JMS(一)
    git 记住用户名和密码
    13 Maven 编写插件
    12 Maven 生成项目站点
    11 Maven 灵活的构建
  • 原文地址:https://www.cnblogs.com/PureJava/p/10497897.html
Copyright © 2011-2022 走看看