파일 목록
-
📁 10
-
📁 3
-
📁 4
-
📁 4-minicalc
-
📁 7
-
📁 parking manager
- 2.cs
- desktop.ini
- Title.png
- 객체지향 3대 특징(+1).txt
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Second
{
internal class Program
{
static void Main(string[] args)
{
/*int numbeer = int.Parse(Console.ReadLine());
해당 방식이면 소숫점 입력시 문제가 발생함 아래는 해결벌*/
int number = 0;
string input = Console.ReadLine();
bool result = int.TryParse(input, out number);
//out은 포인터 같은걸로 뒤에 넘버에다가 변경값을 전달하다는 의미를 갖고있음
if(result == false)
{
Console.WriteLine("입력값이 잘못되었습니다.");
return; // 메소드 종료, 호출한 곳(CLR)로 돌아가란 뜻
}
//if
if (number > 0) {
Console.WriteLine("1.양수");
}
else {
Console.WriteLine("1.양수 아님");
}
//if-ele ifelse
if (number > 0)
{
Console.WriteLine("2.양수");
} else if (number < 0) {
Console.WriteLine("2.음수");
} else
{
Console.WriteLine("2.0");
}
//중첩 if
if (number > 0) {
Console.WriteLine("3.양수");
if (number % 2 == 0) {
Console.WriteLine("4.짝수");
} else { Console.WriteLine("4.홀수"); }
}
else if (number < 0) {
Console.WriteLine("3.음수");
}
else {
Console.WriteLine("3.0");
}
}
}
}
//