山东教师资格证2011心理学课后题答案 第16套题

时间:2011-12-25 00:08:37

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

 

16套题

一、程序填空题

#include    <stdio.h>

void fun(char  *s, char  *p)

{  int  i, j, n, x, t;

   n=0;

   for(i=0; s[i]!=''; i++)  n++;

   for(i=1; i<n-2; i=i+2) {

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

      ___1___;

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

      for(j=___2___+2 ; j<n; j=j+2)

        if(s[t]>s[j]) t=j;

      if(t!=i)

      {  x=s[i]; s[i]=s[t]; s[t]=x; }

   }

   for(i=1,j=0; i<n; i=i+2, j++)  p[j]=s[i];

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

   p[j]=___3___;

}

main()

{  char  s[80]="baawrskjghzlicda", p[50];

   printf("nThe original string is :  %sn",s);

   fun(s,p);

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

}

 

 

二、程序改错题

#include <math.h>

#include <stdio.h>

 

float fun ( float num )

{   int s ;

    float n, t, pi ;

 

    t = 1 ; pi = 0 ; n = 1 ;  s = 1 ;

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

    while(t >= num)

    {

        pi = pi + t ;

        n = n + 2 ;

        s = -s ;

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

        t = s % n ;

    }

    pi = pi * 4 ;

    return pi ;

}

 

main( )

{   float n1, n2 ;

 

    printf("Enter a float number: ") ;

    scanf("%f", &n1) ;

    n2 = fun(n1) ;

    printf("%6.4fn", n2) ;

}

 

 

三、程序编写题

#include <stdio.h>

#include <string.h>

#define LEN 20

 

void fun (char a[], char b[], int n)

{

 

 

 

 

 

}

 

main( )

{   char str1[LEN], str2[LEN] ;

    int n ;

    void NONO (  );

 

    printf("Enter the string:n") ;

    gets(str1) ;

    printf("Enter the index of the char deleted:") ;

    scanf("%d", &n) ;

    fun(str1, str2, n) ;

    printf("The new string is: %sn", str2) ;

    NONO() ;

}

 

void NONO ( )

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

  char str1[LEN], str2[LEN] ;

  int i, n ;

  FILE *rf, *wf ;

 

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

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

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

    fscanf(rf, "%s %d", str1, &n) ;

    fun(str1, str2, n) ;

    fprintf(wf, "%sn", str2) ;

  }

  fclose(rf) ;

  fclose(wf) ;


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

电脑版  |  手机版  |  返回顶部