TOP

山东教师资格证2011心理学课后题答案 第9套题
2011-12-24 23:59:17 来源: 作者: 【 】 浏览:123次 评论:0
微信搜索关注"91考试网"公众号,领30元,获取公务员、事业编、教师等考试资料40G!

9套题

一、程序填空题

#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=%d\n",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("->End\n");

   }

}

 

 

二、程序改错题

#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 == '\0' ) 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 :  %s\n", p);

  else      printf("\nNot found !\n" );

}

 

 

三、程序编写题

#include <stdio.h>

void fun(int a, int b, long *c)

{

 

 

 

}

main()

{  int  a,b; long  c;

   void NONO (  );

   printf("Input a b:");

   scanf("%d%d", &a, &b);

   fun(a, b, &c);

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

   NONO();

}

void NONO (  )

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

  FILE *rf, *wf ;

  int i, a,b ; long c ;

 

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

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

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

    fscanf(rf, "%d,%d", &a, &b) ;

    fun(a, b, &c) ;

    fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c) ;

  }

  fclose(rf) ;

  fclose(wf) ;

}

Tags: 责任编辑:91kaoshiwang
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇山东教师资格证2011心理学课后题.. 下一篇山东教师资格证2011心理学课后题..

相关栏目

最新文章

推荐文章

网站客服QQ: 960335752 - 14613519 - 48225117