C#/알고리즘

5. 14681번 사분면 고르기

dev_sr 2020. 4. 26. 11:27

 

입력받은 값이 어떤 사분면에 있나 보여주기

 

1. 코드

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace _14681
{
    class Program
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            string input2 = Console.ReadLine();
 
            int x = Int32.Parse(input1);
            int y = Int32.Parse(input2);
 
            if(x>0 && y>0)
            {
                Console.WriteLine(1);
            }
            else if(x<0 && y>0)
            {
                Console.WriteLine(2);
            }
            else if(x<0 && y<0)
            {
                Console.WriteLine(3);
            }
            else if(x>0 && y<0)
            {
                Console.WriteLine(4);
            }
        }
    }
}
 
 

 

 

2. 결과값

 

1)

 

2)

 

 

출처

https://www.acmicpc.net/problem/14681