C语言题目10

//求两个数字的最大公约数和最小公倍数
#include"stdio.h"
int main()
{
  int min;
  int max;
  int a;
  int b;
  int swap;
  int remain = 1;
  printf("请输入数字a:");
  scanf("%d", &max);
  printf("请输入数字b:");
  scanf("%d", &min);
  a = max;
  b = min;
  if(min > max)
    {
      swap = min;
      min = max;
      max = swap;
    }
  while(remain!=0)
    {
      remain = max%min;
      max = min;
      min = remain;
    }
  printf("最大公约数为:%d\n", max);
  printf("最小公倍数为:%d\n", a*b/max);
  return 1;
}