Problem A: 2023CSP演练-完善程序-1

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Special Judger Creator:
Submit:224 Solved:108

Description

3. 下面程序的功能是:在含有10个元素的数组中查找最大数,及最大数所在位置(即下标值),最大数可能不止一个。

    例如:若输入

    2  8    5    7    8    4    8    3    2    8

    则应输出

    The max8

    Total4  //最大数出现次数

    The positions1  4  6  9

   【程序】

#include <cstdio>

    #define M 10

    int fun(int *aint  *nint pos[ ])

    {

        int i k max = - 32767;

         k=0; 

        for(i=0; i<M; i++)

            if(  (1)  )  max=a[i];

        for(i=0; i<M; i++)

            if(  (2)  ) pos[k++]=i;

        *n=k;

        return max;

    }

  

    main()

    {

        int a[M]pos[M]i=0 jn;

        printf("Enter 10umber:");

   

        for(i=0; i<M; i++)

           scanf("%d" (3) );

       

       j=fun(   (4)    );

       

       printf("The max:%d\n"j);

        printf("Total: %d\n" n);

        printf("The position:");

       

       for (i=0; i<n;i++)

           printf ("%4d"  (5)  );

        printf("\n");

     return 0;

}  

供选择的答案:

(1)

Aa[i]>m   B. max>a[i]      C. a[i]>max        D. max>i

(2)

Aa[i]>max   B. a[i]==max      C. max>a[i]    D.a[i]>m 

(3)

A&a[i]   B.a[i]     C. &a     D. i+y-x

(4)

Aa n pos   B. &a n pos     C. a &n pos   D. &a &n pos

(5)

Aa[i]   B. a[n]    C. pos[i]   D. pos

Sample Input Copy


Sample Output Copy