TOP

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

6套题

一、程序填空题

#include    <stdio.h>

#include    <stdlib.h>

#define    N    8

typedef  struct list

{  int  data;

   struct list  *next;

} SLIST;

 

void fun( SLIST  *p)

{  SLIST  *t, *s;

   t=p->next;    s=p;

   while(t->next != NULL)

   {  s=t;

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

      t=t->___1___;

   }

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

   printf(" %d ",___2___);

   s->next=NULL;

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

   free(___3___);

}

SLIST *creatlist(int  *a)

{  SLIST  *h,*p,*q;      int  i;

   h=p=(SLIST *)malloc(sizeof(SLIST));

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

   {  q=(SLIST *)malloc(sizeof(SLIST));

      q->data=a[i];  p->next=q;  p=q;

   }

   p->next=0;

   return  h;

}

void outlist(SLIST  *h)

{  SLIST  *p;

   p=h->next;

   if (p==NULL)  printf("\nThe list is NULL!\n");

   else

   {  printf("\nHead");

      do { printf("->%d",p->data);  p=p->next;  } while(p!=NULL);

      printf("->End\n");

   }

}

main()

{  SLIST  *head;

   int  a[N]={11,12,15,18,19,22,25,29};

   head=creatlist(a);

   printf("\nOutput from head:\n");  outlist(head);

   printf("\nOutput from tail: \n");

   while (head->next != NULL){

     fun(head);

     printf("\n\n");

     printf("\nOutput from head again :\n");  outlist(head);

   }

}

 

 

二、程序改错题

#include <stdio.h>

 

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

fun (char a)

{  if ( *a )

   {  fun(a+1) ;

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

      printf("%c" *a) ;

   }

}

 

main( )

{  char s[10]="abcd";

   printf("处理前字符串=%s\n处理后字符串=", s);

   fun(s); printf("\n") ;

}

 

 

三、程序编写题

#include <stdio.h>

char  *fun ( char *s,  char *t)

{

 

 

 

}

 

main( )

{ char a[20],b[20];

  void NONO (  );

  printf("Input 1th string:") ;

  gets( a);

  printf("Input 2th string:") ;

  gets( b);

  printf("%s\n",fun (a, b ));

  NONO ();

}

 

void NONO ( )

{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */

  FILE *fp, *wf ;

  int i ;

  char a[20], b[20] ;

 

  fp = fopen("K:\\k01\\24010001\\in.dat","r") ;

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

  for(i = 0 ; i < 10 ; i++) {

    fscanf(fp, "%s %s", a, b) ;

    fprintf(wf, "%s\n", fun(a, b)) ;

  }

  fclose(fp) ;

  fclose(wf) ;

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

相关栏目

最新文章

推荐文章

网站客服QQ: 960335752 - 14613519 - 48225117