[C++ / C#] 기하 1> 네

백준 3009 – 4번째 포인트

1.C++

#include <iostream>

using namespace std;

int main()
{
	int x1, x2, x3, y1, y2, y3;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

	//직사각형을 만들기 위해 3점이 주어졌을 경우
	//다른 두 점과 다른 좌표의 점이 마지막 x 또는 y의 좌표가 된다.
	if (x1 == x2) {
		cout << x3 << " ";
	}
	else if (x1 == x3){
		cout << x2 << " ";
	}
	else{
		cout << x1 << " ";
	}

	if (y1 == y2){
		cout << y3;
	}
	else if (y1 == y3){
		cout << y2;
	}
	else{
		cout << y1;
	}
}

2. C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Collections;

namespace BaekJoon
{
    class Program
    {
        static void Main(string() args)
        {
            int() posX = new int(3);
            int() posY = new int(3);

            for(int i = 0; i < 3; i++)
            {
                string() input = Console.ReadLine().Split(' ');
                posX(i) = int.Parse(input(0));
                posY(i) = int.Parse(input(1));
            }


            //직사각형을 만들기 위해 3점이 주어졌을 경우
            //다른 두 점과 다른 좌표의 점이 마지막 x 또는 y의 좌표가 된다.

            if (posX(0) == posX(1)){
                Console.Write(posX(2) + " ");
            }
            else if (posX(0) == posX(2)){
                Console.Write(posX(1) + " ");
            }
            else{
                Console.Write(posX(0) + " ");
            }

            if (posY(0) == posY(1)){
                Console.Write(posY(2));
            }
            else if (posY(0) == posY(2)){
                Console.Write(posY(1));
            }
            else{
                Console.Write(posY(0));
            }

        }
    }
}