填空题在一棵二叉树上第6层的结点个数最多是______。
填空题以下程序的功能是将宁符串s中的数字字符放入d数组中,最后输出d中的字符串。例如,输入字符串:abcl23edf4568h,执行程序后输出:123456。请填空。 #include <stdio.h> #include <ctype.h> main() char s[80],d[80]; int i,j; gets(s); for(i=j=0;s[i]!='/0';i++) if( 【20】 ) d[j]=s[i];j++; d[j]='/0'; puts(d);
填空题给定程序中,函数fun的功能是将带头结点的单向链表结点数据域中的数据从小到大排序。即若原链表结点数据域从头至尾的数据为:10、4、2、8、6,排序后链表结点数据域从头至尾的数据为:2、4、6、8、10。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include<stdio.h>
#include<stdlib.h>
#define N 6
typedef struct node{
int data;
struct node *next;
}NODE;
void fun(NODE *h)
{NODE *p,*q;int t;
/**********found**********/
p=______;
while(p){
/**********found**********/
q=______;
while(q){
/**********found**********/
if (p->data______q->data)
{t=p->data;p->data=q->data;q->data=t;}
q=q->next;
}
p=p->next;
}
}
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]={0,10,4,2,8,6};
head=creatlist(a);
printf("/nThe original list:/n");
outlist(head);
fun(head);
printf("/nThe list after sorting:/n");
outlist(head);
}
填空题结构化分析方法是面向______进行分析的方法。
填空题已知字符'A'的ASCII代码值为65,以下程序运行时若从键盘输入:B33 <回车>,则输出结果是 【9】 。 #include <stdio.h> main( ) char a,b; a = getchar( ) ;seanf( "% d" , a=a-'A' +'0';b=b* 2; prinff( "% c % c /n" ,a,b);
填空题以下程序给指针p分配三个double型动态内存单元,请填空。 #include <stdio.h> #include <stdlib.h> main() double *p; p=(double *)malloc( 【7】 ); p[0]=1.5;p[1]=2.5;P[2]=3.5; printf("%f%f%f/n",p[0],p[1],p[2]);
填空题有以下程序 main() int x=1,y=1,z=1; y=y+z;x=x+y; printf("%d",x<y?y:x); printf("%d",x<y?x++:y++); printf("%d",x); printf("%d",y); 运行结果是 【6】
填空题以下程序段打开文件后,先利用fseek函数将文件位置指针定位在文件末尾,然后调用ftell函数返回当前文件位置指针的具体位置,从而确定文件长度,请填空。 FILE*myf; long f1; myf=______("test,t","rb"); fseek(myf,(),SEEK_END) ;f1+ftell(myf); fclose(myf); printf("%1d/n",f1);
填空题下列程序的运行结果是______。
#define P(A) printf("%d",A)
main()
{ int j,a[]={1,2,3,4,5,6,7},i=5;
for(j=3;j>1;j--)
{ switch(j)
{ case 1:
case2:P(a[i++]);break;
case 3:P(a[--i]);
}
}
}
填空题下面的语句定义了结构类型stu,并说明了结构变量person:
struct stu
{
int num;
char name[20];
}person;
若要定义stu的别名PERSON,其正确的定义形式为:______。
填空题下列给定程序中,函数fun的功能是:在形参ss所指字符串数组中查找与形参t所指字符串相同的串,找到后返回该串在字符串数组中的位置(即下标值),若未找到则返回-1。ss所指字符串数组中共有N个内容不同的字符串,且串长小于M。 请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。 注意:部分源程序给出如下。 不得增行或删行,也不得更改程序的结构! 试题程序: #include <stdio.h> #include <string.h> #define N 5 #define M 8 int fun(char (*ss)[M], char *t) int i; /******************found*******************/ for(i=0; i<______; i++) /******************found*******************/ if(strcmp(ss[i], t)==0) return______; return(-1); main() char ch[N][M]("if", "while", "switch", "int", "for", t[M]; int n, i; printf("/nThe original string/n/n"); for(i=0; i<N; i++)puts(ch[i]); printf("/n"); printf("/nEnter a string for search:"); gets(t); n=fun(ch, t); /******************found*******************/ if(n==______) printf("/nDon't found!/n"); else printf("/nThe position is %d./n", n);
填空题以下程序运行后的输出结果是______。
#include<stdio.h>
int main()
{
struct time
{
int h;
int m;
int s;
};
struct time*p, audit={8, 30, 0};
p=
printf("/naudition time is %2d:%2d:%2d", p->h, p->m, p->s);
return 0;
}
填空题以下程序运行后输入:3,abcde<回车>,则输出结果是 【13】 。 # include<string.h> move(char *str,int n) char temp int i; temp=str[n-1); for(i=n-1;i>0;i--)str[i]=str[i-1]; str[0]=temp main() char s[50];iht n,i,z; scanf("%d,%s", z=strlen(s); for(i=1;i<=n;i++)move(s,z); printf("%s/n",s);
填空题下列程序执行后输出的结果是 【9】 。 f(int a) static c=0; c=a+c++ return(C) ; main() int a=2,i,k; for(i=0;i<2;i++) k=f(a++) printf("%d/n",k);
填空题下述程序的输出结果是______。 long fun5(int n) long s; if(n==1)||(n=-2)) s=2: else s=n+fun5(n-1); return(s): main() long x; x=fun5(4); printf("%1d/n",x);
填空题下列给定程序中,函数proc()的功能是:先从键盘上输入一个3行3列的矩阵的各个元素的值,然后输出主对角线元素之积。 请修改函数proc()中的错误,使它能得出正确的结果。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include<stdio.h> void proc() int arr[3][3], mul; int i, j; mul=1; printf("please input an 3*3 array: /n"); for(i=0; i<3; i++) //************found************ for(i=0; j<3; j++) scanf("%d", &arr[i][j]); for(i=0; i<3; i++) //************found************ mul=mul*arr[i][j]; printf("Mul=%d/n", mul); void main() proc();
填空题下列给定程序中,函数fun的功能是:找出100~999(含100和999)所有整数中各位上数字之和为x(x为正整数)的整数,并输出;符合条件的整数个数作为函数值返回。
例如,当x值为5时,100~999各位上数字之和为5的整数有:104,113,122,131,140,203,212,221,230,302,311,320,401,410,500,共有15个。当x值为27时,各位数字之和为27的整数是:999,只有1个。
请在下划线处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
int fun(int x)
{int n,s1,s2,s3,t;
n=0;
t=100;
/********found********/
while(t<=______){
/********found********/
s1=t%10;s2=(______)%10;
s3=t/100;
/********found********/
if(s1+s2+s3==______)
(printf("%d",t);
n++;
}
t++;
}
return n;
}
main()
(int x=-1;
while(x<0)
{printf("Please input(x>0:");
scanf("%d",&x);}
printf("/nThe result is:%d/n",fun(x));
}
}
填空题funl函数的调用语句为funl(。它将3个整数按由大到小的JI匣序调整后依次放入a,b,c三个变量中,a中放最大数,请填空。 void fun2(int *x,int *y) int t; t=*x;*x;*y;*y=t; void funl(int *pa,int *pb,int *pc) if(*pc>*pb) fun2( 【18】 ); if(*pa<*pc) fun2( 【19】 ); if(*pa<*pb) fun2( 【20】 );
填空题有以下语句段
int n1=10,n2=20;
printf("{{U}} 【7】 {{/U}}",n1,n2);
要求按以下格式输出n1和n2的值,每个输出行从第一列开始,请填空。
n1=10
n2=20
填空题给定程序中, 函数 fun 功能是: 找出 100~999 之间(含 100 和 999) 所有整数中各位上数字之和为 x(x 为一正整数) 的整数, 然后输出; 符合条件的整数个数作为函数值返回
