您现在的位置:学赛首页 > 计算机等级考试 > 模拟试题 > 正文
07年9月计算机等级考试二级C语言试卷(Word版)[6]
http://www.educity.cn 作者:希赛等考学院 来源:希赛网 2007年10月17日 发表评论 进入社区

(5)             在E-R图中距形表示_[5]___

(6)             执行以下程序时输入1234567<CR>,则输出结果是_[6]_______.
    #include     <stdio.h>
    main()
    {   int   a=1,b;
    scanf("%2d%2d",&a&b);printf("%d  %d\n",a,b);
    }

(7)             以下程序的功能是:输出a、b、c三个变量中的最小值.请填空。
    #include<stido.h>
    main()
    { int a,b,c,t1,t2;
    scanf("%d%d%d",&a,&b,&c);
    t1=a<b? _[7]_______;
    t2=c<t1? _[8]_______;
    printf("%d\n",t2);
    }

(8)             以下程序的输出结果是_[9]_______.
    #include   <stdio.h>
    main()
    {     int  n=12345,d;
          while(n!=0){  d=n%10;  printf("%d",d); n/=10;}
    }

(9)             有以下程序段,且变量已正确定义和赋值
    for(s=1.0,k=1;k<=n;k++)       s=s+1.0/(k*(k+1));
    printf("s=%f\n\n",s);
    请填空,使下面程序段的功能为完全相同
    s=1.0;k=1;
    while(_[10]_______){ s=s+1.0/(k*(k+1)); _[11]_______;}
    printf("s=%f\n\n",s);

(10)        以下程序的输出结果是_[12]_______.
    #include     <stido.h>
    main()
    {    int   i;
         for(i='a';i<'f';i++,i++)   printf("%c",i-'a'+'A');
         printf("\n");
    }

(11)        以下程序的输出结果是_[13]_______.
    #include   <stdio.h>
    #include    <string.h>
    char  *fun(char   *t)
    {    char      *p=t;
         return(p+strlen(t)/2);
    }
    main()
    {    char   *str="abcdefgh";
         str=fun(str);
         puts(str);
    }

(12)以下程序中函数f的功能是在数组x的n个数(假定n个数互不相同)中找出最大最小数,将其中最小的数与第一个数对换,把最大的数与最后一个数对换.请填空.
    #include    <stdio.h>
    viod    f(int     x[],int     n)
    {     int    p0,p1,i,j,t,m;
          i=j=x[0];          p0=p1=0;
          for(m=0;m<n;m++)
    {    if(x[m]>i)          {i=x[m];  p0=m;}
          else    if(x[m]<j)   {j=x[m];  p1=m;}
    }
    t=x[p0];   x[p0]=x[n-1];     x[n-1]=t;
    t=x[p1];x[p1]= _[14]_______; _[15]_______=t;
    }
    main()
    {   int    a[10],u;
        for(u=0;u<10;u++)     scanf("%d",&a[u]);
    f(a,10);
    for(u=0;u<10;u++)         printf("%d",a[u]);
    printf("\n");
    }

(13)以下程序统计从终端输入的字符中大写字母的个数,num[0]中统计字母A的个数,num[1]中统计字母B的个数,其它依次类推.用#号结束输入,请填空.
    #include     <stdio.h>
    #include      <ctype.h>
    main()
    {     int    num[26]={0},i;      char    c;
          while((_[16]_______)!='#')
             if(isupper(c))     num[c-‘A’]+= _[17]_______;
          for(i=0;i<26;i++)
               Printf("%c:%d\n",i+'A',num[i]);
       }

(14)执行以下程序的输出结果是_[18]_______.
    #include   <stido.h>
    main()
    {    int    i,n[4]={1};
        for(i=1;i<=3;i++)
         {    n[i]=n[i-1]*2+1;   printf("%d",n[i]);      }
    }

(15) 以下程序的输出结果是_[19]_______.
    #include    <stdio.h>
    #define      M       5
    #define       N       M+M
    main()
    {      int    k;
           k=N*N*5;     printf("%d\n",k);
    }

(16)函数main()的功能是:在带头结点的单链表中查找数据域中值最小的结点.请填空
    #include     <stdio.h>
    struct  node
    {   int   data;
    struct  node    *next;
    };
    int min(struct  node *first)/*指针first为链表头指针*/
    {   strct  node   *p;   int   m;
        p=first->next;   m=p->data;p=p->next;
        for(;p!=NULL;p=_[20]_______)
            if(p->data<m)     m=p->data;
       return   m;
    }

[1]  [2]  [3]  [4]  [5]  [6]