二 、填空题
(1)排序是计算机程序设计中的一种重要操作,常见的排序方法有插入排序、 【1】 和选择排序等。
正确答案: 1.(交换排序)
(2)当循环队列非空且队尾指针等于队头指针时,说明循环队列已满,不能进行入队运算。这种情况称为 【2】 。
正确答案: 1.(上溢)
(3) 【3】 是一种信息隐蔽技术,目的在于将对象的使用者和对象的设计者分开。
正确答案: 1.(封装)
(4)为了便于对照检查,测试用例应由输入数据和预期的 【4】 两部分组成。
正确答案: 1.(输出结果)
(5) 【5】 是从二维表列的方向进行的运算。
正确答案: 1.(关系运算)
(6)定义int a=5,b=20;若执行语句printf("%d\n",++a*--b/5%13);后,输出的结果为 【6】 。
正确答案: 1.(9)
(7)执行程序时的输入为123456789,则程序的运行结果为 【7】 。
#include "stdio.h"
main()
{ int a,b;
scanf("%2d%*2d%1d",&a,&b);
printf("%d\n",a-b);}
正确答案: 1.(7)
(8)阅读下面程序,则在执行时候的输出为 【8】 。
#include "stdio.h"
main()
{int x=1,y=2,z=0;
if(x=2)z=x,x=y,y=z;
printf("%d,%d\n",x,y);}
正确答案: 1.(2,2)
(9)语句printf("%d\n",′h′-′0′+64);的执行结果为 【9】 。
正确答案: 1.(88)
(10)阅读下面程序,则程序的执行结果为 【10】 。
#include "stdio.h"
main()
{ int a=10;
fun(a);
printf("%d\n",a);}
fun(int x)
{ x=50;}
正确答案: 1.(10)
(11)以下程序的输出结果是 【11】 。
int fun(int x,int y,int *p,int *q)
{ *p=x*y;
*q=x/y;}
main()
{int a,b,c,d;
a=4;b=3;
fun(a,b,&c,&d);
printf("%d,%d\n",c,d);}
正确答案: 1.(12,1)
(12)下面程序是求出数组arr的两条对角线上元素之和,请填空。
#include "stdio.h"
main()
{int arr[3][3]={2,3,4,8,3,2,7,9,8},a=0,b=0,i,j;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
if( 【12】 )a=a+arr[i][j];
for(i=0;i<3;i++)
for( 【13】 ;j>=0;j--)
if( 【14】 )
b=b+ arr[i][j];
printf("%d,%d\n",a,b);}
正确答案: 1.(i==j ) 2.(j=2) 3.(i+j==2)
(13)下面程序的功能是:对字符串从小到大进行排序并输出,请填空。
#include "string.h"
#include "stdio.h"
sort(char *a[],int n)
{ int i,j;
char *p;
for(j=1;j<=n-1;j++)
for(i=0; 【15】 ;i++)
if( 【16】 >0)
{ p=a[i];
a[i]=a[i+1];
a[i+1]=p;}}
main()
{ int i;
char *book[]={"itisme","itisyou","howareyou","fine","goodnight","goodbye"};
sort( 【17】 );
for(i=0;i<6;i++)
printf("%s\n",book[i]);}
正确答案: 1.(i<n-j) 2.(strcmp(a[i],a[i+1])) 3.(book,6)
(14)下面的函数是完成1~n的累加,完成函数。
a(int k)
{if(k<=0)printf("error\n");
if(k==1) 【18】 ;
else 【19】 ;}
正确答案: 1.(return 1) 2.(return(a(k-1)+k))
(15)阅读下列程序,则程序实现的功能是 【20】 。
#include "stdio.h"
struct node
{ char data;
struct node *next; } *head;
fun(struct node *q)
{ if(head == null)
{q->next=null;
head=q;}
else
{ q->next=head;
head=q;}}
main()
{char ch;
struct node *p;
head = null;
while((ch=getchar())!=′\n′)
{p=(struct node *)malloc(sizeof(struct node));
p->data=ch;
fun(p); }
p=head;
while(p!=null)
{printf("%c",p->data);
p=p->next; }}
正确答案: 1.(从键盘输入一行字符串,调用函数建立反序的链表,然后输出整个链表)
本文共4页:第
[1] [2] [3] [4] 页