using System;
/*計算N個A+B的值
* sampleInput:3
* 1 2
* 3 2
* 4 5
* sampleOutput
* 3
* 5
* 9
*/
//屬于計數(shù)型循環(huán)
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
int N, A, B;
N = Convert.ToInt32(Console.ReadLine());
for(int i=0;i<N;i++)
{
string s = Console.ReadLine();//將A B以字符串讀入
string[] st = s.Split(' ');//分成字符數(shù)組
//進(jìn)行強(qiáng)制轉(zhuǎn)換
A = Convert.ToInt32(st[0]);
B = Convert.ToInt32(st[1]);
//打印A+B
Console.WriteLine("{0}", A + B);
}
}
}
}
結(jié)果
捕獲1.PNG