填空题已知bead指向一个带头结点的单向链表,链表中每个结点包含数据域(data)和指针域(next),数据域为整型。以下函数求出链表中所有连接点数据域的和值作为函数值返回。请在横线处填入正确内容。 int data; struct link *next; main() struct link *head; sam(______); stmct link *p;int s=0; p=head->next; while(p)s+=p->data;p=p->next; return(s);
填空题以下程序运行后的输出结果是 【12】 。 #include <stdio.h> int f( iht a[] ,int n) if(n>=1) returnf(a,n-1) +a[n-1]; else return 0; main( ) int aa[5] = 1,2,3,4,5 ,s; s = f(aa,5); prinff(" % d /n" ,s);
填空题数据流图是描述数据在软件中的流动和变换的过程,而对数据流图中所包含元素的定义则是______。
填空题有以下程序: void swap 1(int c[]) int t; t=c[0];c[0]=c[1];c[1]=t; void swap2(int c0,int c1) int t; t=c0;c0=c1;c1=t; main() int a[2]=3,5,b[2]=3,5; swaplA);swap2(b[0],b[1]); printf("%d,%d,%d,%d/n",a[0],a[1],b[0],b[1]); 其输出结果是 【7】 。
填空题给定程序中,函数fun的功能是计算形参x所指数组中N个数的平均值(规定所有数均为正数),将所指数组中大于平均值的数据移至数组的前部,小于等于平均值的数据移至x所指数组的后部,平均值作为函数值返回,在主函数中输出平均值和移动后的数据。
例如,有10个正数:46 30 32 40 6 17 45 15 48 26,平均值为30.500000。
移动后的输出为46 32 40 45 48 30 6 17 15 26。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
给定源程序如下。
#include<stdlib.h>
#include<stdio.h>
#define N 10
double fun(double*x)
{ int i,j;double s,av,y[N];
s=0;
for(i=0;i<N;i++)s=s+x[i];
/**************found************/
av=______;
for(i=j=0;i<N;i++)
if(x[i]>av){
/***********found*********/
y[______]=x[i];x[i]=-1;}
for(i=0;j<N;i++)
/***********found*********/
if(x[i]!=______)y[j++]=x[i];
for(i=0;i<N;i++)x[i]=y[i];
return av;
}
main()
{ int i;
double x[N]=
{46,30,32,40,6,17,45,15,48,26};
for(i=0;i<N;i++)printf("%4.0f",x[i]);
printf("/n");
printf("/nThe average is:%f/n",fun(x));
printf("/nThe result:/n",fun(x));
for(i=0;i<N;i++)printf("%5.0f",x[i]);
printf("/n"):
}
填空题以下程序段打开文件后,先利用fseek函数将文件位置指针定位在文件末尾,然后调用ftell函数返回当前文件位置指针的具体位置,从而确定文件长度,请填空。
FILE*myf;longfl;
myf={{U}} {{U}} {{/U}} {{/U}}("test.t","rb");
fseek(myf,(),SEEK_END) fl+ftell(myf);
fclose(myf);
printf("%ld/n",fl);
填空题下列给定程序中函数fun的功能是:用选择法对数组中的n个元素进行升序排列。
请修改程序中的错误,使它能得出正确的结果。
注意
:不要改动main函数,不得增行和删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#define N 20
void fun(int a[],int n)
{
int i,j,t,p;
for(j=0;j>n-1;j++)
{
/********found********/
p=j
for(i=j;i<n;i++)
if(a[i]<a[p])
/********found********/
p=j;
t=a[p];a[p]=a[j];a[j]=t;
}
}
void main()
{
int a[N]={9,6,8,3,-1},i,m=5;
printf("排序前的数据:");
for(i=0;i<m;i++)
printf("%d",a[i]);
printf("/n");
fun(a,m);
printf("排序后的顺序:");
for(i=0;i<m;i++)
printf("%d",a[i]);
printf("/n");
}
填空题目前实际存在和使用的广域网基本上都是采用 ______拓扑结构类型。 有以下程序: # include <string.h> struct STU int num; float TotalScore; ; void f(struct STU p) struct STU s[2]=20041,703,20045,537; p.num=s[1].num;p.TotalScore=s[1].TotalScore; main() struct STU s[2]=20041,703,20042,580; f(s[0]); printf("%d %3.0f/n",s[0].num,s[0],TotalScore); 程序运行后的输出结果是 【5】 。
填空题在数据库理论中,数据库总体逻辑结构的改变,如修改数据模式、增加新的数据类型、改变数据间联系等,不需要相应修改应用程序,称为______。
填空题给定程序的功能是分别统计字符串中大写字母和小写字母的个数。 例如,给字符串ss输入:AaaaBBb123CCccccd,则输出结果应为:upper=5,lower=9 注意:部分源程序已给出。 请勿改动函数中的其他内容,仅在横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> void fun(char*8,int*a,int*b) while(*s) if(*s>='A'&&*s<='Z') (1) ; if(*s>='a'&&*s<='z') (2) ; s++: main() char s[100]; int upper=0,lower=0; printf("/nPlease a string:"); gets(s); fun(s,&upper,&lower); printf("/n upper=%d,lower=%d/n", (3) );
填空题数组 int a[3][4];共定义了____________个数组元素。
填空题请补充fun函数,该函数的功能是:将带头结点的单向链表逆置。即若原链表中从头至尾结点数据域依次为:2、4、6、8、10,逆置后,从头至尾结点数据域依次为:10、8、6、4、2。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的行线上填入所编写的若干表达式或语句。 [试题源程序] #include<stdio.h> #include<stdlib.h> #define N 5 typedef struct node int data; struct node * next; NODE; void fun(NODE * h) NODE*P,*q,*r; p= (1) ; if( (2) )return; q=p->next; p->next=NULL; while(q) r=q->next; q->next=p; p=q; q= (3) ; h->next=p; NODE*creatlist(int a[]) NODE*h.*p,*q;int i; h=(NODE*)malloc(sizeof(NODE)); h->next=NULL; for(i=0;i<N;i++) q=(NODE*)malloc(sizeof(NODE)); q->data=a[i]; q->next=NULL; if(h->next==NULL) h->next=p=q; else P->next=q;p=q; return h; void outlist(NODE*h) NODE*P; p=h->next; if(p==NULL) printf("The list is NULL!/n"); else printf("/nHead"); do printf("->%d",p->data);p=p->next; while(p!=NULL); printf("->End/n"); main() NODE*head; int a[N]=2,4,6,8,10; head=creatlist(a); printf("/nThe original list:/n"); outlist(head); fun(head); printf("/nThe list after inverting:/n"); outlist(head);
填空题以下程序中函数huiwen 的功能是检查一个字符串是否是回文,当字符串是回文时,函数数返回字符串:yes!否则函数返回这符串:no!并在主函数中输出。所谓回文即正向与反向的拼写都一样,例如:adgda。请填空 #include <string.h> char*huiwen(char *str) char *p1,*p2; int i,t=0; pl=str; p2=______; for(i=0;i<=strlen(str)/2;i+*) if(*p1++!=*p2--)t=1;break; if(______) return("yes!"); else return(*no!"); main() char str[50]; printf("Input:"); scanf("%s",str); printf("%s/n",______);
填空题请补充fun函数,该函数的功能是:判断一个年份是否为闰年。 例如,1900年不是闰年,2004是闰年。 [注意] 部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。 [试题源程序] #include<stdio.h> #include<conio.h> int fun(int n) int fiag=0; if(n%4==0) if( (1) ) fiag=1; if( (2) )flag=1; return (3) ; void main() int year; clrscr(); printf("Input the year:"); scanf("%d", &year); if(fun(year)) printf("%d is a leap year./n", year); else printf("%d is not a leap year./n", year);
填空题以下程序运行后的输出结果是 【10】 。 main() int a[4][4]=1,2,3,4),5,6,7,8,11,12,13,14,15,16,17,18; int i=0,j=0,s=0; while (i++<4) if (i==2 || i==4)continue; j=0; do S+= a[i][j] ;j++; while (j<4); printf("%d/n",s);
填空题若有定义:int k;,下列程序段的输出结果是{{U}} 【8】 {{/U}}。
for(k=2;k<6;k++,k++)printf("++%d"k);
填空题以下程序运行后的输出结果是 {{U}} 【13】 {{/U}}
main( )
{ int i,n[ ]={0,0,0,0,0};
for(i=1;i<=4;i++)
{ n[i]=n[i-1]*2+1;
printf("%d ",n[i]);
}
}
填空题有以下定义语句,则sizeof(a)的值是 【11】 ,而sizeof(a.share)的值是 【12】 。 struct date int day; int mouth; int year, union int share1; float share2; share; a;
填空题若有定义:int x=1,y=2;float a=3.7,b=2.1;则(x+y)%2+(int)a/(int)b表达式的值为______。
填空题以下程序的输出结果是 【7】 。 main() unsigned short a=65536; int b; printfC%d/n",b=a);