填空题给定程序中,函数fun的功能是:将形参n所指变量中,各位上为偶数的数去除,剩余的数按原来从高位到低位的顺序组成一个新的数,并通过形参指针n传回所指变量。
例如,输入一个数:27638496,新的数:为739。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在
下的BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include<stdio.h>
void fun(unsigned long *n)
{ unsigned long x=0, i; int t;
i=1;
While(*n)
/**********found**********/
{t=*n%______;
/**********found**********/
if(t%2!=______)
{x=x+t*i; i=i*10;}
*n=*n/10;
}
/**********found**********/
*n=______;
}
main()
{ unsigned long n=-1;
while(n>99999999||n<0)
{printf("Please input(0<n<100000000):");
scanf("%ld", }
fun(
printf("/nThe result is:%ld/n", n);
}
填空题下列给定程序中已建立了一个带头结点的单向链表,在main()函数中将多次调用fun()函数,每调用一次,输出链表尾部结点中的数据,并释放该结点,使链表缩短。
请在标号处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。不得增行或删行,也不得更改程序的结构。
试题程序 #include
<stdio.h> #include <stdlib.h> #define N
8 typedef struct list { int data;
struct list *next; } SLIST; void
fun(SLIST *p) { SLIST *t, *s; t=p->next;
s=p; while(t->next! =NULL) { s=t;
t=t->______; } printf("% d",
______); s->next=NULL; free(______);
} 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=NULL; 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
a[N]={11,12,15,18,19,22,25,29}; head=creatlist (a);
printf("/nOutput from head:/n");
outlist(head); printf("/nOutput from tail:/n");
while(head->next!=NULL){ fun(head);
printf("/n/n"); printf("/nOutput from head
again:/n"); outlist(head); }
}
填空题下列程序的输出结果是{{U}} 【10】 {{/U}}。
int t(int x,int y,int cp,int dp)
{ cp=x*x+y*y;
dp=x*x-y*y;
}
main()
{ int a=4,b=3,c=5,d=6;
t(a,b,c,d);
printf("%d%d/n",c,d);
}
填空题以下程序中给指针p分配三个double型动态内存单元,请填空。
# include <stdlib.h>
main ( )
{ double *p;
p=(double *) malloc(【 】);
p[0]=1.5;p[1]=2.5;p[2]=3.5;
printf(“%f%f%f/n”,p[0],p[1],p[2]); }
填空题若按功能划分,软件测试的方法通常分为白盒测试方法和{{U}} 【1】 {{/U}}测试方法。
填空题设变量已正确定义为整型,则表达式n=i=2,++i,i++的值为______。
填空题下列给定程序中,函数fun的功能是:利用指针数组对形参ss所指字符串数组中的字符串按由长到短的顺序排序,并输出排序结果。ss所指字符串数组中共有N个字符串,且串长小于M。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意
:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<string.h>
#define N 5
#define M 8
void fun(char(*ss)[M])
{char *ps[N],*tp;int i,j,k;
for(i=0;i<N;i++)
ps[i]=ss[i];
for(i=0;i<N-1;i++)
{
/********found********/
k=______;
for(j=i+l;j<N;j++)
/********found********/
if(strlen(ps[k]<strlen(______))k=j;
/********found********/
tp=ps[i];ps[i]ops[k];ps[k]=______;
}
printf("/nThe string after sorting by length:/n/n");
for(i=0;i<N;i++)puts(ps[i]);
}
main()
{char ch[N][M]={"red","green","blue","yellow","black"};
int i;
printf("/nThe original string/n/n");
for(i=0;i<N;i++)puts(ch[i]);
printf("n");
fun(ch);
}
填空题下列给定程序中,函数fun的功能是:计算N×N矩阵的主对角线元素和反向对角线元素之和,并作为函数值返回。要求先累加主对角线元素中的值,再累加反向对角线元素中的值。 例如,若N=3,有下列矩阵: 1 2 3 4 5 6 7 8 9 首先累加1、5、9,然后累加3、5、7,函数返回值为30。 请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。 注意:部分源程序给出如下。 不得增行或删行,也不得更改程序的结构! 试题程序: #include<stdio.h> #defineN4 fun(int t[][N],int n) int i,sum; /***********found***********/ ______; for(i=0;i<n;i++) /************found**********/ sum+=______; for(i=0;i<n;i++) /**********found***********/ sum+=t[i][n-i-______]; return sum; main() int t[][N]=21,2,13,24,25,16,47,38,29,11,32,54,42,21,3,10,i,j; printf("/nThe original data:/n"); for(i=0;i<N;i++) for(j=0;j<N;j++) printf("%4d",t[i][j]); printf("/n"); printf("The result is:%d",fun(t,N));
填空题以下程序运行后的输出结果是{{U}} 【17】 {{/U}}。
#include <stdio, h>
#include <string, h>
main( )
{ char ch[] ="abc".,x[3] [4]: int i:
for(i=0;i<3:i ++) strcpy(x[i] ,ch):
for(i =0;i<3:i++) printf( "% s" ,
printf(" /n" )
}
填空题已知a为8位二进制数,要想通过a^b运算使a的低5位变反(即0变1,1变0),高3位不变,b的值应为 【17】 。
填空题以下程序的功能是:通过函数func输入字符并统计输入字符的个数,输入时用字符@作为输入结束标志。请填空。 #include<stdio.h> long______; /*函数说明语句*/ main() long a; a=func(); printf("n=%1d/n", a); long func() long b; for(b=0; getchar()!='@'; b++; ); return b;
填空题下列给定程序中,函数fun的功能是:根据整型形参n,计算如下公式的值。
A
1
=1,A
2
=1/(1+A
1
),A
3
=1/(1+A
2
),…,A
n
=1/(1+A
(n-1)
)
例如,若n=10,则应输出0.617977。
请改正程序中的锴误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
/**********found**********/
int fun(int n)
{
float A=1;int i;
/**********found**********/
for(i=2;i<n;i++)
A=1.0/(1+A);
return A;
}
void main()
{
int n;
system("CLS");
printf("/nPlease enter n:");
scanf("%d",
printf("A%d=%lf/n",n,fun(n));
}
填空题(在每对/**/之间填写内容,完成题目的要求)
填空题给定程序中,函数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<= (1) ) /**********found**********/ s1=t%10;s2= (2) %10;s3=t/100; /**********found**********/ If(s1+s2+s3= (3) ) printf("%d",t); n++; t++; return n; main() int x=-1; While(x<0) printf("Please input(x>0):"); Scanf("%d", Printf("/nThe result is:%d/n",fun(x));
填空题以下程序运行时若从键盘输入:10 20 30<回车>,输出结果是{{U}} 【10】 {{/U}}。
# include<stdio.h>
main()
{ int i=0,j=0,k=0;
scanf("%d% *d%d",printf("%d %d %d/n",i,j,k);
}
填空题请补充main()函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组tt中并输出,把其他字符保存在tt[10]中。
例如,当str1=“00237481367539dfji”时,结果为
0:21:12:13:34:15:16:17:28:19:1
other charactor:4
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void main()
int i,tt[11];
char*str="00237481367539dfji";
char*p=str;
syslem("CLS");
printf("***the origial data***/n");
puts(str);
for(i=0;i<11;i++)
tt[i]=0;
while(*p)
{
switch(______)
{
case"0":tt[0]++;break;
case"1";tt[1]++;break;
case"2":tt[2]++;break;
case"3":tt[3]++;break;
case"4":tt[4]++;break;
case"5":tt[5]++;break;
case"6":tt[6]++;break;
case"7":tt[7]++;break;
case"8":tt[8]++;break;
case"9":tt[9]++;break;
______
}
______
}
printf("****the result****/n");
for(i=0;i<10;i++)
printf("/n%d:%d",i,tt[i]);
printf("/nother charactor:%d",tt[i]);
}
填空题若有定义:int a=5, b=2, c=1; ,则表达式a-b<c||b==c的值是______。
填空题以下程序打开新文件f.txt,并调用字符输出函数将a数组中的字符写入其中,请填空。 #include <stdio.h> main() ______*fp; char a[5]='1','2','3','4','f5',i; f=fopen("______","w"); for(i=0;1<5;i++)fputc(a[i],fp); fclose(fp);
填空题以下程序的功能是输出如下形式的方阵:
13 14 15 16
9 10 11 12
5 6 7 8
1 2 3 4
请填空。
main()
{int i,j,x;
for(j=4;j{{U}} 【17】{{/U}};j--)
{for(i=1;i<=4;i++)
{x=(j-1)*4 +{{U}} 【18】 {{/U}};
printf("%4d",x);
}
printf("/n");
}
}
填空题下列程序的运行结果为{{U}} 【8】 {{/U}}。
main()
{ int a[3]C4}={{1,3,5,7},{2,4,6,8},{15,17,34,12}};
printf("max value is %d/n",max value(3,4,a));
}
max value(m,n,array)
int m,n,array[][4];
{ int i,j,max;
max=array[0][0];
for(i=0;i<m;i++)
for(i=0;i<n;j++)
if(max<array[i][j])max=array[i][j];
return(max);
}
