알고리즘/백준 문제풀이

백준 14681번, 언어 : C99

ya_ya 2020. 12. 24. 17:42
반응형
#include <stdio.h>


typedef struct Coordinate {

	int x; // Coordinate of x
	int y; // Coordinate of y

	int Quad; //Quadrant(사분면) ex)1,2,3,4

} Coord;

int main() {

	Coord c1; 

	scanf("%d %d", &c1.x, &c1.y);

	//case1 x>0
	if (c1.x > 0) {
		if (c1.y > 0) printf("1 \n");
		else if (c1.y < 0) printf("4 \n");
		else printf("On the x-axis \n");
	}

	//case2 x<0
	else if (c1.x < 0) {
		if (c1.y > 0) printf("2 \n");
		else if (c1.y < 0) printf("3 \n");
		else printf("On the x-axis \n");
	}

	else printf("On the y-axis \n");

	return 0;
}
반응형