分享

Advanced 1001 A+B Format

 悟道习术 2021-04-03

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


C#源码

using System;

namespace _1001 { 

    class Program

    {

        static void Main(string[] args)

        {

                string strIn = Console.ReadLine();

                String[] strArr = strIn.Split(' ');

                int  intA = int.Parse(strArr[0]);

                int intB = int.Parse(strArr[1]);

                int intOut = intA + intB;

            //Console.WriteLine(string.Format("{0:#,###0.#}",intOut));

            Console.WriteLine(intOut.ToString("N"));//N2,保留两位小数

        }

    }

}

题目比较简单:

  1.  计算两个数的和

  2. 然后将计算结果以千位分隔符的方式显示出来……

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多