백준 10951번 A + B - 4(JAVA, C#) hasNextInt()
자바
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
while(sc.hasNextInt())
{
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a+b);
}
sc.close();
}
}
[백준] 10951번 : A+B - 4 - JAVA [자바]
https://www.acmicpc.net/problem/10951 10951번: A+B - 4 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net 문제 간단한 문제지만 의외로 종료시점을 몰라 틀리는 경우들이 많
st-lab.tistory.com
참고해야겠다.
/////////////////////////////
C#
using System;
namespace Baekjoon {
class Program {
static void Main(string[] args) {
while(true)
{
string c = Console.ReadLine();
if(c == null)
{
break;
}
string[] ss = c.Split();
int a = int.Parse(ss[0]);
int b = int.Parse(ss[1]);
Console.WriteLine(a+b);
}
}
}
}
/// EOF(End Of File)를 이용하는 거란다.