스토리지

[3.10] - 제한된 범위 내에서 두 정수의 합 본문

Unity/수업내용(C#)

[3.10] - 제한된 범위 내에서 두 정수의 합

ljw4104 2021. 3. 10. 12:31
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Study01
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("정수 입력 : ");
            string tmp1 = Console.ReadLine();
            Console.Write("정수 입력 : ");
            string tmp2 = Console.ReadLine();

            int t1 = Convert.ToInt32(tmp1);
            int t2 = Convert.ToInt32(tmp2);

            if (Math.Abs(t1) > 100 && Math.Abs(t2) > 100)
            {
                Console.WriteLine("범위를 벗어났습니다.");
            }
            else
            {
                Console.WriteLine("sum : {0}", t1 + t2);
            }
        }
    }
}

Comments