C语言题目10

IT小小龙 posted @ 2014年4月06日 16:18 in C with tags 辗转相除 , 550 阅读
//求两个数字的最大公约数和最小公倍数
#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;
}
Avatar_small
Junior Certificate R 说:
2022年8月28日 16:00

The Rajshahi Board is also completed the Junior School Certificate and Junior Dakil (Grade-8) terminal exams successfully under Secondary and Higher Secondary Education Board, and a huge number of students have appeared from all districts of Rajshahi Division, and those subject wise exams are completed between 1st to 3rd weeks at all schools across the country along with the divisional schools to the academic year of 2022. Both of JSC & JDC students are waiting to check their exam result with full marksheet in student wise to get total GPA grade for this year terminal exams, Junior Certificate Result Sylhet Board Grade 8th standard is the most important examination for secondary education in the country and this is gateway to secondary education in the country, and the school education department will announce student wise result with total marksheet online and this year also published same like as previous years.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter