0910二级C语言笔试不懂的.docx

上传人:b****6 文档编号:7315498 上传时间:2023-01-22 格式:DOCX 页数:12 大小:83.61KB
下载 相关 举报
0910二级C语言笔试不懂的.docx_第1页
第1页 / 共12页
0910二级C语言笔试不懂的.docx_第2页
第2页 / 共12页
0910二级C语言笔试不懂的.docx_第3页
第3页 / 共12页
0910二级C语言笔试不懂的.docx_第4页
第4页 / 共12页
0910二级C语言笔试不懂的.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

0910二级C语言笔试不懂的.docx

《0910二级C语言笔试不懂的.docx》由会员分享,可在线阅读,更多相关《0910二级C语言笔试不懂的.docx(12页珍藏版)》请在冰豆网上搜索。

0910二级C语言笔试不懂的.docx

0910二级C语言笔试不懂的

(9)以下程序运行后的输出结果是【9】s=0

#include

main()

{intk=1,s=0;

do{

if{((k&2)!

=0)continue;

s+=k;k++;

}while(k)10);

printf(“s=&d/n”,s);

}

(10)下列程序运行时,若输入labced12df<回车>输出结果为【10】

#include

main()

{char

a=0,ch;

while((ch=getchar())!

=’\n’)

{if(a&2!

=0&&(ch>’a’&&ch<=’z’))ch=ch-‘a’+’A’;

a++;putchar(ch);

}

printf(“\n”);

}

(11)有以下程序,程序执行后,输出结果是【11】

#include

voidfun(int*a)

{a[0=a[1];]}

main()

{inta[10]={10,9,8,7,6,5,4,3,2,1},i;

for(i=2;i>=0;i--)fun{&a};

for(i=0;i<10;i++)printf(“&d”,a);

printf(“\n”);

}

(14)下列程序的运行结果为【14】1001,ChangRong,1098.0

#include

#include

structA

{inta;charb[10];double

c;};

void

f(struct

A

*t);

main()

{structAa=(1001,”ZhangDa”,1098,0);

f(&a);printf(“&d,&s,&6,if\n”,a.a,a.b,a.c);

}

voidf(struct

A

*t)

{strcpy(t->b,”ChangRong”);

}

(15)以下程序把三个NODETYPE型的变量链接成一个简单的链表,并在while循环中输出链表结点数据域中的数据,请填空

#include

structnode

{intdata;structnode*next;};

typedefstructnodeNODETYPE;

main()

{NODETYPEa,b,c,*h,*p;

a.

data=10;b.data=20;c.data=30;h=&a;

b.

next=&b;b.next=&c;c.next=’\0’;

p=h;

while(p){printf(“&d”,p->data);【15】p=p—>next;}

C(24)有以下程序

#include 

void fun(int p)

{  int d=2;

   p=d++; 

   printf("%d",p);

}

main()

{  int a=1;

   fun(a);

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

}

程序运行后的输出结果是

A)32

B)12

C)21

D)22

D(25)以下函数findmax拟实现在数组中查找最大值并作为函数值返回,

但程序中有错导致不能实现预定功能

#define MIN -

int findmax(int x[],int n)

{  int i,max;

   for(i=0;i   {  max=MIN;

      if(max   }

   return max;

}

造成错误的原因是

A)定义语句int i,max中max未赋值

B)赋值语句max=MIN;中,不应该给max赋MIN值

C)语句if(maxD)赋值语句max=MIN;放错了位置

A(27)若有定义语句:

 int a[4][10],*p,*q[4];且0<=i<4,则错误的赋值是

A)p=a

B)q[i]=a[i]

C)p=a[i]

D)p=&a[2][1]

A(33)设有以下函数:

void fun(int n,char *s){……}

则下面对函数指针的定义和赋值均正确的是

A)void (*pf)(); pf=fun;

B)void *pf();  pf=fun;

C)void *pf(); *pf=fun;

D)void (*pf)(int,char);pf=&fun;

C(34)有以下程序

#include 

int f(int n);

main()

{  int a=3,s;

   s=f(a);s=s+f(a);printf("%d\n",s);

}

int f(int n)

{ static int a=1;

  n+=a++;

  return n;

}

程序运行后的输出结果是

A)7

B)8

C)9

D)10

B(36)下面结构体的定义语句中,错误的是

A)struct ord {int x;int y;int z;};struct ord a;

B)struct ord {int x;int y;int z;} struct ord a;

C)struct ord {int x;int y;int z;} n;

D)struct {int x;int y;int z;} a;

D(38)有以下程序

#include 

struct A

{ int a;char b[10];double c;};

struct A f(struct A t);

main()

{ struct A a={1001,"ZhangDa",1098.0};

  a=f(a); printf("%d,%s,%6.1f\n",a.a,a.b,a.c);

}

struct A f(struct A t)

{ t.a=1002;strcpy(t.b,"ChangRong");t.c=1202.0;return t;}

程序运行后的输出结果是

A)1001,ZhangDa,1098.0

B)1002,ZhangDa,1202.0

C)1001,ChangRong,1098.0

D)1002,ChangRong,1202.0

(8)以下程序运行后的输出结果是【8】

#include 

main()

{  int x=20;

   printf("%d ",0   printf("%d\n",0}

输入答案,中间不含空格:

(9)以下程序运行后的输出结果是【9】

#include 

main()

{  int a=1,b=7;

   do{

      b=b/2;a+=b;

   } while (b>1);

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

}

输入答案,中间不含空格:

(10)有一下程序

#include 

main()

{  int f,f1,f2,i;

   f1=0;f2=1;

   printf("%d %d ",f1,f2);

   for(i=3;i<=5;i++)

   { f=f1+f2; printf("%d",f);

     f1=f2; f2=f;

   }

   printf("\n");

}

程序运行后的输出结果是【10】

输入答案,中间不含空格:

(11)有以下程序

#include 

int a=5;

void fun(int b)

{  int a=10;

   a+=b; printf("%d",a);

}

main()

{  int c=20;

   fun(c); a+=c; printf("%d\n",a);

}

程序运行后的输出结果是【11】

输入答案,中间不含空格:

(12)设有定义

struct person

{ int ID;char name[12];} p;

请将scanf("%d",【12】);语句补充完整,使其能够为结构体变量p的

成员ID正确读入数据。

输入答案,中间不含空格:

 

(14)有以下程序

#include 

typedef struct

{ int num;double s;} REC;

void fun1(REC x){ x.num=23;x.s=88.5; }

main()

{ REC a={16,90.0};

  fun1(a);

  printf("%d\n",a.num);

}

输入答案,中间不含空格:

(15)有以下程序

#include 

fun(int x)

{  if(x/2>0) fun(x/2);6,3,

   printf("%d ",x);

}

main()

{ fun(6);printf("\n");}

程序运行后的输出结果是【15】

  (36)有以下程序

  #include<stdio.h>

  intfun()

  {staticintx=1;

  x+=1;returnx;

  }

  main()

  {inti;s=1;

  for(i=1;i<=5;i++)s+=fun();

  printf(”%d\n”,s);

  }

  程序运行后的输出结果是

  A)11

  B)21

  C)6

  D)120(37)有以下程序

  #inctude<stdio.h>

  #include<stdlib.h>

  Main()

  {int*a,*b,*c;

  a=b=c=(int*)malloc(sizeof(int));

  *a=1;*b=2,*c=3;

  a=b;

  printf(“%d,%d,%d\n”,*a,*b,*c);

  }

  程序运行后的输出结果是

  A)3,3,3B)2,2,3C)1,2,3D)1,1,3

  (38)有以下程序

  #include<stdio.h>

  main()

  {ints,t,A=10;doubleB=6;

  s=sizeof(A);t=sizeof(B);

  printf(“%d,%d\n”,s,t);

  }

  在VC6平台上编译运行,程序运行后的输出结果是

  A)2,4B)4,4C)4,8D)10,6

(39)若有以下语句

  TypedefstructS

  {intg;charh;}T;

  以下叙述中正确的是

  A)可用S定义结构体变量

  B)可用T定义结构体变量

  C)S是struct类型的变量

  D)T是structS类型的变量

 (40)有以下程序

  #include<stdio.h>

  main()

  {shortc=124;

  c=c_______;

  printf(“%d\n”、C);

  }

  若要使程序的运行结果为248,应在下划线处填入的是

  A)>>2B)|248C)&0248D)<

  请将每空的正确答案写在答题卡【1】至【15】序号的横线上,答在试卷上不得分。

  

(1)一个栈的初始状态为空。

首先将元素5,4,3,2,1依次入栈,然后退栈一次,再将元素A,B,C,D依次入栈,之后将所有元素全部退栈,则所有元素退栈(包括中间退栈的元素)的顺序为【1】

  

  

(2)在长度为n的线性表中,寻找最大项至少需要比较【2】次。

  (3)一棵二叉树有10个度为1的结点,7个度为2的结点,则该二叉树共有【3】个结点(4)仅由顺序、选择(分支)和重复(循环)结构构成的程序是【4】程序。

  (5)数据库设计的四个阶段是:

需求分析,概念设计,逻辑设计【5】。

  (6)以下程序运行后的输出结果是【6】。

  #include<stdio.h>

  main()

  {inta=200,b=010;

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

  }

 (7)有以下程序

  #include<stdio.h>

  main()

  {intx,Y;

  scanf(”%2d%ld”,&x,&y);printf(”%d\n”,x+y);

  }

  程序运行时输入:

程序的运行结果是【7】。

  (8)在C语言中,当表达式值为0时表示逻辑值“假”,当表达式值为【8】时表示逻辑值“真”。

有以下程序

  #include<stdio.h>

  main()

  {inti,n[]={0,0,0,0,0};

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

  {n[i]=n[i-1]*3+1;printf(”%d",n[i]);}

  }

  程序运行后的输出结果是【9】。

 (10)以下fun函数的功能是:

找出具有N个元素的一维数组中的最小值,并作为函数值返回。

请填空。

(设N已定义)

  intfun(intx[N])

  {inti,k=0;

  for(i=0;i

  if(x[i]

  returnx[k];

  }

  (11)有以下程序

  #include<stdio.h>

  int*f(int*p,int*q);

  main()

  {intm=1,n=2,*r=&m;

  r=f(r,&n);printf(”%d\n”,*r);

  }

  int*f(int*p,int*q)

  {return(*p>*q)?

p:

q;}

  程序运行后的输出结果是【11】

(12)以下fun函数的功能是在N行M列的整形二维数组中,选出一个最大值作为函数值返回,请填空。

(设M,.N已定义)

  intfun(inta[N][M))

  {inti,j,row=0,col=0;

  for(i=0;i

  for(j=0;j

  if(a[i][j]>a[row][col]){row=i;col=j;}

  return(【12】):

  }(13)有以下程序

  #include<stdio.h>

  main()

  {intn[2],i,j;

  for(i=0;i<2;i++)n[i]=0;

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

  for(j=0;j<2;j++)n[j]=n「i」+1;

  printf(”%d\n”,n[1]);

  }

  程序运行后的输出结果是【13】

(14)以下程序的功能是:

借助指针变量找出数组元素中最大值所在的位置并输出该最大值。

请在输出语句中填写代表最大值的输出项。

  #include<stdio.h>

  main()

  {inta〔10],*p,*s;

  for(p=a;p-a<10;p++)scanf(”%d”,p);

  for(p=a,s=a;p-a<10;p++)if(*p>*s)S=P;

  printf("max=%d\n”,【14】);

  }

 (15)以下程序打开新文件f.txt,并调用字符输出函数将a数组中的字符写入其中,请填空。

#include<stdio.h>

  main()

  {【15】*fp;

  chara[5]={’1’,’2’,’3’,’4’,’5’},i;

  fp=fopen(”f.txt”,”w”);

  for(i=0;i<5;i++)fputc(a[i],fp);

  fclose(fp);

 

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1