TOP

2012全国计算机二级C语言(C++)题库 第22套题
2011-12-25 00:17:03 来源: 作者: 【 】 浏览:148次 评论:0
微信搜索关注"91考试网"公众号,领30元,获取公务员、事业编、教师等考试资料40G!

22套题

一、程序填空题

#include  <stdio.h>

int fun(int  x)

{ int  n, s1, s2, s3, t;

  n=0;

  t=100;

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

  while(t<=__1__){

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

    s1=t%10;  s2=(__2__)%10;  s3=t/100;

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

    if(s1+s2+s3==__3__)

    {  printf("%d ",t);

       n++;

    }

    t++;

  }

  return  n;

}

main()

{ int x=-1;

  while(x<0)

  { printf("Please input(x>0): ");  scanf("%d",&x);  }

  printf("\nThe result is: %d\n",fun(x));

}

 

 

二、程序改错题

#include <stdio.h>

 

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

void fun (long  s, long t)

{   long  sl=10;

    s /= 10;

    *t = s % 10;

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

    while ( s < 0)

    {  s = s/100;

       *t = s%10*sl + *t;

       sl = sl * 10;

    }

}

 

main()

{  long   s, t;

   printf("\nPlease enter s:"); scanf("%ld", &s);

   fun(s, &t);

   printf("The result is: %ld\n", t);

}

 

 

三、程序编写题

#include <stdio.h>

#define   N   16

typedef  struct

{  char  num[10];

   int   s;

} STREC;

void  fun( STREC  a[] )

{

 

 

}

 

main()

{  STREC  s[N]={{"GA005",85},{"GA003",76},{"GA002",69},{"GA004",85},

                  {"GA001",91},{"GA007",72},{"GA008",64},{"GA006",87},

                  {"GA015",85},{"GA013",91},{"GA012",64},{"GA014",91},

                  {"GA011",66},{"GA017",64},{"GA018",64},{"GA016",72}};

   int  i;FILE *out ;

   fun( s );

   printf("The data after sorted :\n");

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

   {  if( (i)%4==0 )printf("\n");

      printf("%s  %4d  ",s[i].num,s[i].s);

   }

   printf("\n");

   out = fopen("K:\\k01\\24010001\\out.dat","w") ;

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

   {  if( (i)%4==0 && i) fprintf(out, "\n");

      fprintf(out, "%4d  ",s[i].s);

   }

   fprintf(out,"\n");

   fclose(out) ;

}

 

Tags: 责任编辑:91kaoshiwang
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇2012全国计算机二级C语言(C++)题.. 下一篇2012全国计算机二级C语言(C++)题..

相关栏目

最新文章

推荐文章

网站客服QQ: 960335752 - 14613519 - 48225117