C#に戻って学習します。
Hangdianのオンライン裁判官はC#をサポートしていますが、これは練習用です。
http://acm.hdu.edu.cn/showproblem.php?pid=1000
リファレンス:https : //blog.csdn.net/fcxxzux/article/details/54573392
入る:
複数の行があり、各行にはスペースで区切られた2つの整数aおよびbがあります。
出力:
各行a + bの結果は1行を占めます。
C#で解決します。主なポイントは次のとおりです。
1.キーボードから行を読みます。文字列s = Console.ReadLine();
2.読み終わりの条件を判断します。if(s == null)break;
3.文字列をスペースで区切ります。string [] a = s.Split( '');
4.データ型変換。int b = Convert.ToInt32(a [0]);
5. 1行出力します。Console.WriteLine(b);
完全なコードは次のとおりです。
using System;
namespace test
{
class Program
{
static void Main(string[] args)
{
string s ;
while(true)
{
s = Console.ReadLine();
if (s == null)
break;
string[] a = s.Split(' ');
int b, c;
b = Convert.ToInt32(a[0]);
c = Convert.ToInt32(a[1]);
Console.WriteLine(b + c);
}
}
}
}