c#的一道计算多组 A B的题目
2019-09-27 本文已影响0人
李药师_hablee
using System;
/*计算N个A+B的值
* sampleInput:3
* 1 2
* 3 2
* 4 5
* sampleOutput
* 3
* 5
* 9
*/
//属于计数型循环
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(' ');//分成字符数组
//进行强制转换
A = Convert.ToInt32(st[0]);
B = Convert.ToInt32(st[1]);
//打印A+B
Console.WriteLine("{0}", A + B);
}
}
}
}