计算机等级 > 二级考试 > C语言程序设计 > C语言模拟试题 > 文章内容

全国计算机等级考试C语言考试程序填空题(15)

2016-6-1编辑:ljnbset

在考生文件夹下,给定程序FILL.C的功能是:

求两个正整数x,y的最大公约数和最小公倍数。

例如:如果x=24,y=36,程序的输出应为:

  max is : 12

min is : 72 。

 

  #include

  #include

  #include

  void main()

  { int x,y,t,max,min,i,n1,n2;

    printf("Please enter two numbers:");

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

    if(x > y)

     {t = x; x = y; y = t;}

    n1=x; n2=y;

    t = n2 % n1;

  /************found************/

while(t!=0)

    while( ____(1)____ )

    {

      n2 = n1 ;

      n1 = t ;

      t = n2 % n1;

    }

  /************found************/

max=n1;

    max = ____(2)____ ;

    min = x * y / max ;

   printf("max is : %d\n",max);

   printf("min is : %d\n",min);

}

全国计算机等级考试C语言考试程序填空题(14)

热点推荐

登录注册
触屏版电脑版网站地图