TOP

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

2套题

一、程序填空题

#include    <stdio.h>

#include    <string.h>

#include    <stdlib.h>

void WriteText(FILE *);

void ReadText(FILE *);

main()

{  FILE  *fp;

   if((fp=fopen("myfile4.txt","w"))==NULL)

   {  printf(" open fail!!\n"); exit(0);  }

   WriteText(fp);

   fclose(fp);

   if((fp=fopen("myfile4.txt","r"))==NULL)

   {  printf(" open fail!!\n"); exit(0);  }

   ReadText(fp);

   fclose(fp);

}

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

void WriteText(FILE  ___1___)

{  char  str[81];

   printf("\nEnter string with -1 to end :\n");

   gets(str);

   while(strcmp(str,"-1")!=0) {

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

      fputs(___2___,fw);  fputs("\n",fw);

      gets(str);

   }

}

void ReadText(FILE  *fr)

{  char  str[81];

   printf("\nRead file and output to screen :\n");

   fgets(str,81,fr);

   while( !feof(fr) ) {

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

     printf("%s",___3___);

     fgets(str,81,fr);

   }

}

 

 

二、程序改错题

#include <stdio.h>

 

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

void fun (long  s, long t)

{   long   sl=10;

    *t = s % 10;

    while ( s > 0)

    {   s = s/100;

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

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

         sl = sl*100;

    }

}

 

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;

int  fun( STREC  *a, STREC *b )

{

 

 

}

 

main()

{  STREC  s[N]={{"GA05",85},{"GA03",76},{"GA02",69},{"GA04",85},

                  {"GA01",91},{"GA07",72},{"GA08",64},{"GA06",87},

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

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

   STREC  h[N];

   int  i,n;FILE *out ;

   n=fun( s,h );

   printf("The %d lowest score :\n",n);

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

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

   printf("\n");

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

   fprintf(out, "%d\n",n);

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

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

   fclose(out);

}

 

 

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

相关栏目

最新文章

推荐文章

网站客服QQ: 960335752 - 14613519 - 48225117