View Code of Problem 59

#include <stdio.h>
#include <string.h>
#include <math.h>
#define N 100
int main()
{
	int a, b, t, c, d, gys, gbs;
	scanf_s("%d %d", &a, &b);
	if (a < b)
	{
		t = b;
		b = a;
		a = t;
	}
	c = a, d = b;
	gys = a % b;
	if (gys == 0)
	{
		gbs = a * b / gys;
		printf("%d %d", gbs, gys);
	}
	else
	{
		while (gys)
		{
			a = b;
			b = gys;
			gys = a % b;
		}
		gys = b;
		gbs = c * d / gys;
		printf("%d %d", gbs, gys);
	}

}
/*
Main.c: In function 'main':
Main.c:8:2: warning: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
  scanf_s("%d %d", &a, &b);
  ^~~~~~~
  scanf
/usr/bin/ld: /tmp/ccTuhmEM.o: in function `main':
Main.c:(.text.startup+0x18): undefined reference to `scanf_s'
collect2: error: ld returned 1 exit status
*/

Double click to view unformatted code.


Back to problem 59