글
백준 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();
}
}
참고해야겠다.
/////////////////////////////
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)를 이용하는 거란다.
'백준 프로그래밍' 카테고리의 다른 글
백준 10807번 개수 세기(JAVA, C#) (0) | 2023.02.15 |
---|---|
백준 1110번 더하기 사이클(JAVA, C#) (0) | 2023.02.15 |
백준 10952번 A+B - 5(JAVA, C#) while문 (0) | 2023.02.15 |
백준 2439번 별 찍기 - 2(JAVA, C#) (0) | 2023.02.15 |
백준 별 찍기 - 1(JAVA, C#) (0) | 2023.02.14 |