2012二级上机模拟题1(一)

时间:2012-06-10 20:35:10

微信搜索关注"91考试网"公众号,领30元,获取事业编教师公务员等考试资料40G

第一套:

填空:

#include    <stdio.h>

#include    <stdlib.h>

#define    N    8

typedef  struct list

{  int  data;

   struct list  *next;

} SLIST;

SLIST *creatlist(int  *a);

void outlist(SLIST  *);

void fun( SLIST  *h, int  *n)

{  SLIST  *p;

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

   ___1___=0;

   p=h->next;

   while(p)

   {  (*n)++;

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

      p=p->___2___;

   }

}

main()

{  SLIST  *head;

   int  a[N]={12,87,45,32,91,16,20,48}, num;

   head=creatlist(a);    outlist(head);

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

   fun(___3___, &num);

   printf("nnumber=%dn",num);

}

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("The list is NULL!n");

   else

   {  printf("nHead ");

      do

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

      while(p!=NULL);

      printf("->Endn");

   }

}

 

改错:

#include  <stdio.h>

#include  <string.h>

 

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

{

  char   *p , *r, *a;

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

  a = Null;

  while ( *s )

  {   p = s;   r = t;

      while ( *r )

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

        if ( r == p )

        { r++;  p++; }

        else  break;

      if ( *r == '' ) a = s;

      s++;

  }

  return  a ;

}

 

main()

{

  char   s[100], t[100], *p;

  printf("nPlease enter string S :"); scanf("%s", s );

  printf("nPlease enter substring t :"); scanf("%s", t );

  p = fun( s, t );

  if ( p )  printf("nThe result is :  %sn", p);

  else      printf("nNot found !n" )

}

 

编程:

#include <stdio.h>

#include <string.h>

 

void fun(char *s, char t[])

{

 

 

 

}

 

main()

{

  char   s[100], t[100];

  void NONO (  );

  printf("nPlease enter string S:"); scanf("%s", s);

  fun(s, t);

  printf("nThe result is: %sn", t);

  NONO();

}

特别提醒:由于NONO()函数是系统批改上机考试分数用的函数,与考生无关,考生


首页 上页 1 2 下页 尾页 1/2/2
微信搜索关注"91考试网"公众号,领30元,获取公务员事业编教师考试资料40G
【省市县地区导航】【考试题库导航】