第三处答" />
最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

二级C语言上机题库及答案

来源:动视网 责编:小OO 时间:2025-09-24 21:05:25
文档

二级C语言上机题库及答案

第一套题上机填空:#includedoublefun(doublee)s=0;k=1;i=2;/**********found**********/x=__1__/4;/**********found**********/while(x__2__e){s=s+k*x;/**********found**********/}returns;}main(){doublee=1e-3;printf("\\nTheresultis:%f\\n",fun(e));第一处答案:3.0第二处答案:>第三处答
推荐度:
导读第一套题上机填空:#includedoublefun(doublee)s=0;k=1;i=2;/**********found**********/x=__1__/4;/**********found**********/while(x__2__e){s=s+k*x;/**********found**********/}returns;}main(){doublee=1e-3;printf("\\nTheresultis:%f\\n",fun(e));第一处答案:3.0第二处答案:>第三处答
第一套题

上机填空:

#include

double fun(double  e)

  s=0;  k=1;  i=2;

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

  x=__1__/4;

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

  while(x __2__ e)

  { s=s+k*x;

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

  }

  return  s;

}

main()

{ double  e=1e-3;

  printf("\\nThe result is: %f\\n",fun(e));

第一处答案: 3.0

第二处答案:>

第三处答案:(2*i+1) 或者(t+1)

上机改错题:

#include

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

void fun (  int  n )

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

}

main( )

{   int   n = 5;

}

第一处改错:将:void fun (  int  n ) 改为 double fun (  int  n )

第二处改错:s = s + (Double)a / b; 改为 s = s + (double)a / b;

第二套题

上机填空题

#include

double fun(int  n)

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

  s=__1__;

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

for(i=1; i<=__2__; i++)

  { t=2.0*i;

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

  }

  return  s;

}

main()

{ int  n=-1;

while(n<0)

{ printf("Please input(n>0): "); scanf("%d",&n); }

  printf("\\nThe result is: %f\\n",fun(n));

第一处空答案:0

第一处空答案:n

第三处空答案:(t*t)

改错题

#include

int fun (char *str,char *substr)

{  int i,j,k,num=0;

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

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

}

main()

{

  char str[80],substr[80];

  printf("Input a string:") ;

  gets(str);

  printf("Input a substring:") ;

  gets(substr);

  printf("%d\\n",fun(str,substr));

}

第一处错误:for(i = 0, str[i], i++) 改为for(i = 0; str[i];i++)

第二处错误:If(substr[k+1]=='\\0') 改为if(substr[k+1]=='\\0') 即是将”If”改为”if”

第三套题

填空题

void fun(char  *s, int  *t)

{  int i, n;

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

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

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

}

main()

{  char  s[80]="abcdef35adgh3kjsdf7";

}

第一空:s第二空:’9’  第三空:*t=n

改错题:

#include

int fun(int *x,int y)

{

  int t ;

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

  t = x ; x = y ;

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

  return(y) ;

}

main()

{

  int a = 3, b = 8 ;

  printf("%d  %d\\n", a, b) ;

  b = fun(&a, b) ;

  printf("%d  %d\\n", a, b) ;

}

第一处改错:将  t = x ; x = y ;改为

第二处改错:将 return(y) 改为return(t)

第四套题:

填空题

#define    N    9

int fun(int  a[], int  n)

{  int  i,j;

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

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

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

}

main()

{  int  b[N]={9,1,4,2,3,6,5,8,7}, i, n;

}

第一处 1  第二处: j++  第三处:

改错题

#include

int  fun(int  a,int  b)

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

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

}

main()

{  int  num1, num2,a;

   printf("Input  num1  num2:   "); scanf("%d%d",&num1,&num2);

}

第一处错误:t=a; b=a; a=t; 改为 t=a;a=b;b=t;

第二处错误:return(a) 改为 return b或者 return(b);

求最大公约数算法一般采用辗转相除法。辗转相除法的算法为:首先将 m除以 n(m>n)得余数 r,再用余数r去除原来的除数,得到新的余数,重复此过程直到余数为 0时停止,此时的除数就是m 和 n的最大公约数。

第五套题:

填空题:

#include

unsigned long fun(unsigned long  n)

  while(n)

  { t=n%10;

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

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

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

  }

  return  x;

}

main()

{ unsigned long  n=-1;

while(n>99999999||n<0)

{ printf("Please input(0  printf("\\nThe result is: %ld\\n",fun(n));

}

第一空:0  第二空: 第三空:n/10

改错题:

#include

void fun (long  s, long *t)

  long  sl=1;

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

  t = 0;

while ( s > 0)

  {  d = s%10;

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

  }

}

main()

{  long s, t;

}

第一处错误:将t=0改为*t=0;

第二处错误:将d%2 == 0 改为 d%2!=0

第六套题:

#define    N    9

void fun(int  a[], int  n)

{  int  i,j, max, min, px, pn, t;

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

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

         {   max = a[j]; px = j;  }

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

         {   min = a[j]; pn = j;  }

}

main()

{  int  b[N]={9,1,4,2,3,6,5,8,7}, i;

}

第一处空:a[i];

第二处空:a[j]

第三处空:a[j]

改错题:

#include

long fun(int  g)

{

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

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

}

main()

{  long   fib;    int   n;

}

第一处错误:将 switch(g); 改为 switch(g) ,即是去掉“;”

第二处错误:将  case 1 ;case 2 : return 1 ;改为case 1 :case 2 : return 1 ;即是将case1 后“;”改为“:”

第七套题:

填空题

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

___1___ fun(char  ch)

{

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

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

}

main()

{  char  c1, c2;

   c1='2';   c2 = fun(c1);

   printf("c1=%c    c2=%c\\n", c1, c2);

   c1='8';   c2 = fun(c1);

   printf("c1=%c    c2=%c\\n", c1, c2);

   c1='a';   c2 = fun(c1);

   printf("c1=%c    c2=%c\\n", c1, c2);

}

第一空:char 

第二空:ch>=’9’

第三空:’0’

改错题:

#include

void  fun(char  *p, char  *b)

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

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

}

main()

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

   printf("Enter a string:      ");  gets(a);

   printf("\\nThe string after insert space:   ");  puts(b); printf("\\n\\n");

}

第一处:将b[k]=p; 改为b[k]=*p;

第二处:将b[k++]=" ";改为b[k++]=’  ’;

第8套题

填空题

#define    M    5

#define    N    20

int fun(char  (*ss)[N], int  *n)

{  int  i, k=0, len= N;

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

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

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

}

main()

{  char  ss[M][N]={"shanghai

}

第一空:M

第二空:<

第三空:K

改错题:

#include

#include

char* fun( char tt[] )

{

  int i;

  for( i = 0; tt[i]; i++ )

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

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

  return( tt );

}

main( )

{

  char tt[81];

  printf( "\\nPlease enter a string: " );

  gets( tt );

  printf( "\\nThe result string is:\\n%s", fun( tt ) );

}

第一处错误:将“||”改为“&&”

第二处错误:将 tt[i] += 32; 改为tt[i] -= 32;

第9套题:

填空题:

void fun(char  *s)

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

  t2[j]=0;  t1[k]=0;

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

for(i=0; i/**********found**********/

for(i=0; i<___3___; i++) s[k+i]=t2[i];

}

main()

{  char  s[80]="ba3a54j7sd567sdffs";

}

第一处空:j++

第二处空:a[i]=t1[i];

第三处空:j

改错题

#include

#include

#define MAXLINE 20

fun ( char *pstr[6])

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

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

}

main( )

}

第一处错误:for (j = i + 1, j < 6, j++) 改为for (j = i + 1;j < 6; j++)

第二处错误:  *(pstr + i) = pstr + j ;改为  *(pstr + i) = *(pstr + j) ;

第10套题

填空题

typedef  struct list

{  int  data;

} SLIST;

void fun( SLIST  *h, int  x)

{  SLIST  *p, *q, *s;

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

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

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

}

SLIST *creatlist(int  *a)

}

void outlist(SLIST  *h)

{  SLIST  *p;

   {   printf("\\nHead");

}

main()

}

第一处空:x

第二处空:p

第三处空:s

改错题:

#include

long  fun (long num)

{

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

  long k;

  do

  { k*=num%10 ;

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

  } while(num) ;

  return  (k) ;

}

main( )

{ long n ;

  printf("\\nPlease enter a number:") ;  scanf("%ld",&n) ;

  printf("\\n%ld\\n",fun(n)) ;

}

第一处错误:将long k;改为:long k=1;

第二处错误:将num\\=10 ;改为num/=10 ;

第11套题

填空题

#define    N    9

void fun(int  a[], int  n)

{  int  i, t, p;

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

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

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

}

main()

{  int  b[N]={1,2,3,4,5,6,7,8,9}, i;

}

第一空:1

第二空:i

第三空:a[p+i]

改错题:

#include

void  fun(float *a,float *b,float *c)

{

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

if( *a<*b )

   {   k=*a; *a=*b; *b=k; }

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

   {   k=*c; *c=*a; *a=k; }

   {   k=*b; *b=*c; *c=k; }

}

main()

}

第一处错误:将” 改为

第二处错误:if( *a>*c ) 改为 if( *a<*c )

第12套题

填空题

#include

#include

#define   N   5

#define   M   10

int fun(char  (*ss)[M], int  k)

{ int  i,j=0,len;

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

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

  {  len=strlen(ss[i]);

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

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

  }

  return  j;

}

main()

{ char  x[N][M]={"Beijing

  int  i,f;

  printf("\\nThe original string\\n\\n");

for(i=0;i  f=fun(x,7);

  printf("The string witch length is less than or equal to 7 :\\n");

for(i=0; i}

改错题

#include

#include

void  fun(char *p ,char *q, char *c)

{

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

  int k = 1;

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

       else         c[k]=*p;

}

main()

}

第13套题

文档

二级C语言上机题库及答案

第一套题上机填空:#includedoublefun(doublee)s=0;k=1;i=2;/**********found**********/x=__1__/4;/**********found**********/while(x__2__e){s=s+k*x;/**********found**********/}returns;}main(){doublee=1e-3;printf("\\nTheresultis:%f\\n",fun(e));第一处答案:3.0第二处答案:>第三处答
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top