TOP

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

8套题

一、程序填空题

#include    <stdio.h>

#include    <stdlib.h>

#define    N    8

typedef  struct list

{  int  data;

   struct list  *next;

} SLIST;

SLIST *creatlist(char  *);

void outlist(SLIST  *);

int fun( SLIST  *h, char  ch)

{  SLIST  *p;        int  n=0;

   p=h->next;

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

   while(p!=___1___)

   {   n++;

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

       if (p->data==ch)  return ___2___;

       else  p=p->next;

   }

   return 0;

}

main()

{  SLIST  *head;       int  k;      char  ch;

   char  a[N]={'m','p','g','a','w','x','r','d'};

   head=creatlist(a);

   outlist(head);

   printf("Enter a letter:");

   scanf("%c",&ch);

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

   k=fun(___3___);

   if (k==0)   printf("\nNot found!\n");

   else       printf("The sequence number is :  %d\n",k);

}

SLIST *creatlist(char  *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("->%c",p->data);  p=p->next;  }

     while(p!=NULL);

     printf("->End\n");

  }

}

 

 

二、程序改错题

#include <string.h>

#include <stdio.h>

#include <ctype.h>

fun ( char *p)

{  int i,t;  char c[80];

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

   For (i = 0,t = 0; p[i] ; i++)

      if(!isspace(*(p+i))) c[t++]=p[i];

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

   c[t]="\0";

   strcpy(p,c);

}

 

main( )

{  char c,s[80];

   int i=0;

   printf("Input a string:");

   c=getchar();

   while(c!='#')

   {  s[i]=c;i++;c=getchar(); }

   s[i]='\0';

   fun(s);

   puts(s);

}

 

 

三、程序编写题

#include <stdio.h>

#include <string.h>

void  fun  ( char *ss )

{

 

 

 

}

 

main( )

{ char tt[81] ;

  void NONO (  );

  printf( "\nPlease enter an string within 80 characters:\n" ); gets( tt );

  printf( "\n\nAfter changing, the string\n  \"%s\"", tt );

  fun( tt );

  printf( "\nbecomes\n  \"%s\"\n",  tt  );

  NONO ( );

}

 

void NONO ( )

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

  FILE *fp, *wf ;

  char tt[81] ;

  int i ;

 

  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", tt) ;

    fun( tt ) ;

    fprintf(wf, "%s\n", tt) ;

  }

  fclose(fp) ;

  fclose(wf) ;

}

 

Tags: 责任编辑:91kaoshiwang
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇山东教师资格证2011心理学课后题.. 下一篇2012全国计算机二级C语言(C++)题..

相关栏目

最新文章

推荐文章

网站客服QQ: 960335752 - 14613519 - 48225117