background image

      scanf("%f",&x);

      amax=x;

      amin=x;

      while (____

                                          _______)

      {

        if (x>amax)

           amax=x;

        else if (x<amin)

           amin=x;

        scanf("%f',&x);

       }

       printf("\namax=%f\namin=%f\n",amax,amin);

   }

4.设 n 是整型变量,且已具有某正整数值。根据下述数学式

    

求 s 的值并输出。可编写如下之程序段来实现。请填空。

   int k;

   double s,d;

   s=0.0;

   d=1.0;

   k=0;

   do

   {

     s=s+d;

     ___                                  _

   ________;

     d=1.0/(k*(k+1));

    } while (k<=n);

    printf("%f\n",s);

5.执行下述程序的输出结果是____

                   _

   ___。

   #include <stdio.h>

1

1

1

4

1

3

1

3

1

2

1

2

1

+

+

+

+

+

n

n