using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.Write("첫번째 숫자를 입력하세요 : ");
int a = Convert.ToInt32(Console.ReadLine());
Console.Write("두번째 숫자를 입력하세요 : ");
int b = Convert.ToInt32(Console.ReadLine());
if ((a > 10000) || (a < -10000) && ((b > 10000) || (b < -10000)))
{
Console.WriteLine("잘못된 입력입니다");
}
if ((a < 10000) && (a > -10000) && ((b < 10000) && (b > -10000)))
{
if (a > b)
{
Console.WriteLine("A > B");
}
if (a < b)
{
Console.WriteLine("A < B");
}
if (a == b)
{
Console.WriteLine("A == B");
}
}
}
}
}
둘다 10000을 입력했을때 의도와는 다른 결과가 나왔는데
원인은 단순했다.
조건설정시에 10000을 포함하는 크거나 같다, 작거나 같다 의 =를 깜빡했다.
'C# > 수업 과제' 카테고리의 다른 글
알고리즘 연습문제 (0) | 2021.12.24 |
---|---|
if문 문제만들어서 풀기 (0) | 2021.12.24 |
스레드 SCV Work 공유자원 동기화 (0) | 2021.12.24 |
OX퀴즈 (0) | 2021.12.24 |
탱크와 벌쳐 전투 (0) | 2021.12.24 |