Advanced 1001 A+B Format

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,b≤106. 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)

相关推荐