填空题有以下程序(说明:字符0的ASCII码值为48):
#include<stdio.h>
main()
{char c1, c2;
scanf("%d", &c1);
c2=c1+9;
printf("%c%c/n", c1, c2);
}
若程序运行时从键盘输入48<回车>,则输出结果为______。
填空题下面程序的运行结果是______。 #include<stdio.h> main() char a[80],*p"AbabCDcd"; int i=0,j=0; while(*(p++)!='/0') if(*p>='a'&&*p<='z') a[i]=*p;i++; a[i]='/0'; puts(a);
填空题下列程序的功能是计算1~100的整数的累加和。 main() int i, sum=______; i=1; for(______) sum+=i; i++; printf("sum=%d/n",______);
填空题下面程序执行后输出的结果是{{U}} 【8】 {{/U}}。
int m=13;
int fun(int x,int y)
{ int m+3;
return(x*y-m);
}
main()
{ int a=7,b,5;
prntf("%d/n",fun(a,B) /m);
}
填空题设变量a和b已正确定义并赋初值。请写出与a=a+b等价的赋值表达式{{U}} 【6】 {{/U}}。
填空题程序通过定义学生结构体变量,存储了学生的学号、姓名和3门课的成绩。函数fun的功能是将形参a所指结构体变量S中的数据进行修改,并把a中的地址作为函数值返回到主函数,在主函数中输出修改后的数据。 例如,a所指变量s中的学号、姓名和3门课的成绩依次是:10001、"ZhangSan"、95、80、88,修改后输出t中的数据应为:10002、"LiSi"、96、81、89。 请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。 文件BLANK1.C内容如下: #include<stdio.h> #include<string.h> struct student long sno; char name[10]; float score[3]; ; /**********found**********/ (1) fun(struct student *a) int i; a->sno=10002: strepy(a->name,"LiSi"); /**********found**********/ for(i=0;i<3;i++) (2) +=1; /**********found**********/ return (3) ; void main( ) struct student s=10001,"ZhangSan",95,80,88, *t; int i; printf("in/nThe original data: in"); printf("/nNo: %1d Name: %s/nScores: ",s.sno,s.name); for(i=0;i<3;i++) printf("%6.2f",s.score[i]); printf("/n"): t=fun(&s); printf("/nThe data after modified:/n"); printf("/nNo: %1d Name: %s/nScores: ",t->sno,t->name); for(i=0;i<3;i++) printf("%6.2f",t->score[i]); printf("/n");
填空题如果一个工人可管理多个设施,而一个设施只可被一个工人管理,则实体“工人”与实体“设备”之间存在{{U}} 【1】 {{/U}}联系。
填空题请补充函数proc(),该函数的功能是:把数组aa中元素下标为奇数的元素按从大到小的顺序重新保存在原数组中,其他元素位置不变。
例如,若数组aa中的元素为:“45 65 40 32 13 57 88 90 67 99”,则输出结果为:“45 99 40 90 13 65 88 57 67 32”。
注意:部分源程序中的给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define M 10
void proc(int aa[])
{
int i, j, t;
for(______; i<M; i=i+2)
{
for(j=i; j<M; j=j+2)
if(aa[i]<aa[j])
{
______;
aa[j]=aa[i];
______;
}
}
}
void main()
{
int i;
int aa[M]={45, 65, 40, 32, 13, 57, 88, 90, 67, 99};
system("CLS");
printf("/n***original list***/n");
for(i=0; i<M; i++)
printf("%4d", aa[i]);
proc(aa);
printf("/n***new list***/n");
for(i=0; i<M; i++)
printf("%4d", aa[i]);
}
填空题常见的拓扑结构有 【4】 。
填空题下列给定程序中已建立一个带头结点的单向链表,链表中的各结点按结点数据域中的数据递增有序链接。函数fun的功能是:把形参x的值放入一个新结点并插入链表中,使插入后各结点数据域中的数据仍保持递增有序。 请在下画线处填入正确的内容并将下画线删除,使程序得出正确的结果。 注意:部分源程序给出如下。 不得增行或删行,也不得更改程序的结构! 试题程序: #include <stdio.h> #include <stdlib.h> #define N 8 typedef struct list int data; struct 1ist * next; SLIST; void fun(SLIST * h, int x) SLIST * P, * q, * s; s=(SLIST* )malloc(sizeof(SLIST)); /********** found********** / s->data=______; q=h; p=h->next; while(p! =NULL p=p->next; s->next=p; /********** found********** / q->next=______; SLIST * creatlist(int * 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("->% d", p->data); p=p->next; while(p!=NULL); printf("->End/n"); main() SLIST * head; int x; int a[N]=11, 12, 15, 18, 19, 22, 25, 29; head=creatlist(a); printf("/nThe list before inserting: /n"); outlist(head); printf("/nEnter a number: "); scanf("%d", fun(head, x); printf("/nThe list after inserting: /n"); outlist(head);
填空题程序通过定义学生结构体数组,存储若干名学生的学号、姓名和三门课的成绩。函数fun的功能是:将存放学生数据的结构体数组,按姓名的字典序(从小到大)排序。
请在程序的下画线处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <string.h>
struct student {
long sno;
char name[10];
float score[3];
};
void fun(struct student a[], int n)
{
/**********found**********/
______t;
int i, j;
/**********found**********/
for(i=0; i<______; i++)
for(j=i+1; j<n; j++)
/**********found**********/
if(strcmp(______)>0)
{ t = a[i]; a[i] = a[j];
a[j] = t;
}
}
main()
{ struct student s[4]={{10001,"ZhangSan",95,80,88},{10002,"LiSi",85,70,78},{10003,"CaoKai",75,60,88},{10004,"FangFang",90,82,87}};
int i,j;
printf("\n\nThe original data:\n\n");
for(j=0; j<4; j++)
{ printf("\nNo:%ld Name:%-8s Scores: ",s[j].sno,s[j].name);
for(i=0; i<3; i++)
printf("%6.2f",s[j].score[i]);
printf("\n");
}
fun(s,4);
printf("\n\nThe data after soring:\n\n");
for(j=0; j<4; j++)
{ printf("\nNo:%td Name:%-8s Scores:",s[j].sno,s[j].name);
for(i=0; i<3; i++)
printf("%6.2f",s[j].score[i]);
printf("\n");
}
}
填空题设Y是int型变量,请写出判断Y为奇数的关系表达{{U}} {{U}} {{/U}}{{/U}}。
填空题函数check用来判断字符串s是否是“回文”(顺读和倒读都一样的字符串为“回文”,如abeba)。是则函数返回值1,否则返回值0,请填空。 int check(char *s) char *p1,*p2;int n; n=strlen(s); p1=s; p2= 【14】 ; while(p1<p2) if (*p1 != *p2) break; else p1++;p2--; if( 【15】 )return 0; else return 1;
填空题某二叉树有5个度为2的结点及3个度为1的结点,则该二叉树中共有______个点。
填空题已有定义double *p;,请写出完整的语句,利用malloc函数使p指向一个双精度型 的动态存储单元_________。
填空题若a=10,b=20,则表达式!(a<b)的值是 【7】 。
填空题设x和y均为int型变量,且x=1,y=2,则表达式double(1+x/y)的值为{{U}} 【12】 {{/U}}。
填空题以下程序运行后的输出结果是{{U}} 【13】 {{/U}}。
void swap(int x,int y)
{int t;
t=x;x=Y;Y=t;printf("%d%d",x,y);
}
main()
{int a=3,b=4;
swap(a,b);printf("%d%d",a,b);
}
填空题给定程序中,函数fun的功能是:将a所指4×3矩阵中第k行的元素与第0行元素交换。
例如,有下列矩阵:
1 2 3
4 5 6
7 8 9
10 11 12
若k为2,程序执行结果为:
7 8 9
4 5 6
1 2 3
10 11 12
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include<stdio.h>
#define N 3
#define M 4
/**********found**********/
void fun(int (*a)[N], int______)
{ int i, temp;
/**********found**********/
for(i=0; i<______; i++)
{temp=a[0][i];
/**********found**********/
a[0][i]=______;
a[k][i]=temp;
}
}
main()
{ int x[M][N]={ {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}}, i, j;
printf("The array before moving:/n/n");
for(i=0; i<M; i++)
{ for(j=0; j<N; j++)printf("%3d", x[i][j]);
printf("/n/n");
}
fun(x, 2);
printf("The array after moving:/n/n");
for(i=0; i<M; i++)
{ for{j=0; j<N; j++)printf("%3d", x[i][j]);
printf("/n/n");
}
}
填空题假定整数数列中的数不重复,并存放在数组中。下列给定程序中函数fun的功能是:删除数列中值为x的元素,变量n中存放数列中元素的个数。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#define N 20
fun(int *a,int n,int x)
{
int o=0,i;
a[n]=x;
while(x!=a[p])
P=p+1;
/*********found*********/
if(p==n)
return-1;
else
{
for(i=p;i<n;i++)
/*********found*********/
a[i+1]=a[i];
return n-1;
}
}
void main()
{
int w[N]={-3,0,1,5,7,99,10,15,30,90},x,n,i;
n=10;
printf("The original data:/n");
for(i=0;i<n;i++)
printf("%5d",w[i]);
printf("/nInput x(to delete):");
scanf("%d",
printf("Delete:%d/n",x);
n=fun(w,n,x);
if(n==-1)
printf("***No be found!***/n/n");
else
{
printf("The data after deleted:/n");
for(i=0;i<n;i++)
printf("%5d",w[i]);
printf("/n/n");
}
}