프로그래밍 언어/C언어

CODE GROUND > 연습문제 > 일차방정식

B612 2021. 7. 16. 14:29
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int t;
	int test;
	int j;

	int a, c, d;
	char b, e, f;

	setbuf(stdout, NULL);
	scanf("%d\n", &t);
	
	for (test = 0; test < t; test++) {
		scanf("%d %c %c %d %c %d", &a, &b, &e, &c, &f, &d);
		printf("Case #%d\n", test + 1);
		d += c;
		j = a;

		for (j; j > 0; j--) {
			if (a % j == 0 && d % j == 0) {
				printf("%d / %d\n", d / j, a / j);
				break;
			}
		}
	}
	return 0;
}

입출력이 번갈아 된다는게 항상 헷갈린단 말이지,,,문제 많이 풀며 익숙해져야 될 것 같다!