10952번 - A+B - 5
using System;
using System.Globalization;
using System.Text;
namespace Egh
{
public class Program
public static void Main(string[] args)
while (true)
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
Console.WriteLine(a + b);
if (a == 0 && b == 0)
return;
}
코드는 코드 올리는 곳(밑에 있습니다..)에 올려주세요. 다 깨져서 보기 불편합니다.
여튼 런타임 에러인 이유는 숫자가 한줄에 2개 올라오는데 여기서는 Console.ReadLine() 2개써서 두 줄을 읽기 때문입니다.
Spilt()으로 나눠 받으면 됩니다.
그리고 결과 출력하기 전에 a + b를 출력하면 마지막에 0 0 나올때 0을 출력해서 틀릴겁니다.
댓글을 작성하려면 로그인해야 합니다.
magicboy01 3년 전
using System;
using System.Globalization;
using System.Text;
namespace Egh
{
public class Program
{
public static void Main(string[] args)
{
while (true)
{
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
Console.WriteLine(a + b);
if (a == 0 && b == 0)
{
return;
}
}
}
}
}