填空题设有char a,b;,若要通过a&b运算屏蔽掉a中的其他位,只保留第2位和笫8位(右起为第1位),则b的二进制是 【8】 。
填空题下列给定的程序中,函数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;
}
}
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");
}
填空题多媒体计算机所用的CD-ROM是{{U}} 【3】 {{/U}}。
填空题请补充函数fun(),该函数的功能是:返回字符数组中指定子符的个数,指定字符从键盘输入。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#define N 80
int fun (char s[],char ch)
{
int i=0, n=0;
while({{U}} 【1】 {{/U}})
{
if({{U}} 【2】 {{/U}})
n++;
i++;
}
{{U}} 【3】 {{/U}};
}
main ( )
{
int n;
char str[N], ch;
clrscr ();
printf ("/nInput a string: /n");
gets (str);
printf ("/nInput a charactor: /n" ;
scanf ("%c",
n=fun (str, ch);
printf("/nnumber of %c:%d", ch, n);
}
填空题若有如下程序: main() int x=20; if(x>10)printf("%d",x-=5); if(x>15)printf("%d",x); 则程序运行后的输出结果是 【11】 。
填空题若有以下程序:
main()
{ int a[4][4]={{1,2,-3,-4},{0,-12,-13,14},{-21,23,0,-24},{-31,32,-33,0}};
int i,j,s=0;
for(i=0;i<4;i++)
{for(j=0;j<4;j++)
{if (a[i][j]<0)
continue;
if(a[i][j]==0)
break;
s+=a[i][j];
}
}
printf("%d/n",s);
}
执行后的输出结果是{{U}} 【14】 {{/U}}。
填空题
给定程序MODI1.C中函数fun的功能是:输出M行M列整数方阵,然后求两条对角线上元素之和,返回此和数。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
给定源程序:
#include<stdio.h>
#define M 5
/**********found**********/
int fun(int n, int xx[][])
{ int i, j, sum=0;
printf("/nThe %d x %d matrix:/n", M, M);
for(i=0; i<M; i++)
{ for(j=0; j<M; j++)
/**********found**********/
printf("%f", xx[i][j]);
printf("/n");
}
for(i=0; i<n; i++)
sum+=xx[i][i]+xx[i][n-i-1];
return(sum);
}
main()
{ int aa[M][M]={{1, 2, 3, 4, 5}, {4, 3, 2, 1, 0},
{6, 7, 8, 9, 0}, {9, 8, 7, 6, 5}, {3, 4, 5, 6, 7}};
printf("/nThe sum of all elements on 2 diagnals is %d.", fun(M, aa));
}
填空题给定程序中,函数fun的功能是将a和b所指的两个字符串分别转换成面值相同的整数,并进行相加作为函数值返回,规定字符串中只含9个以下数字字符。
例如,主函数中输入字符串32486和12345,在主函数中输出的函数值为44831。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
给定源程序如下。
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define N 9
long ctod(char*s)
{ long d=0;
while(*s)
if(isdigit(*s)){
/***********found**********/
d=d*10+*s-______;
/***********found*********/
______;}
return d;
}
long fun(char *a,char *b)
{
/***********found**********/
return ______;
}
main()
( char s1[N],s2[N];
do
{ printtf"Input string s1:");gets(s1);}
while(strlen(s1)>N);
do
{ printf("Input string s2:");gets(s2);}
while(strlen(s2)>N);
printf("The result is:%ld/n",fun(s1,s2));
}
填空题以下程序的运行结果是 【12】 。 #include<stdio.h> main() int a=1,b=2,c; c=max(a,b); printf("max is%d/n",c); max(int x,int y) int z; z=(x>y)? x:y; return(z);
填空题下列程序段的输出结果是 【8】 。int n='c';switch(n++) default:printf("error");break; case 'a':case 'A':case 'b':case 'B':printf("good");break; case 'c':case 'C':printf("pass"); case 'd':case 'D':printf("warn");
填空题以下程序运行后的输出结果是{{U}} 【7】 {{/U}}。
#define S(x)4*x*x+1
mah()
{ int i=6,j=8;
printf("%d/n",S(i+j));
}
填空题请补充main()函数,该函数的功能是:从键盘输入两个字符串并分别保存在字符数组str1和str2中,用字符串str2替换字符串str1前面的所有字符,且str2的长度不大于str1,否则需要重新输入。
例如,如果输入str1="abcdefg",str2="hij",则输出"hijdefg"。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在main()函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
void main()
{
char str1[81],str2[81];
char*p1=str1,*p2=str2;
system("CLS");
do
{
printf("Input str1/n");
gets(str1);
printf("Input str2/n");
gets(str2);
while(______);
while(______)
*p1++=*p2++;
printf("Display str1/n");
puts(______);
}
}
填空题给定程序中, 函数 fun 的功能是: 找出 100 至 x(x999) 之间各位上的数字之和为 15 的所有整数, 然后输出; 符合条件的整数个数作为函数值返回
填空题以下程序是建立一个名为myfile的文件,并把从键盘输入的字符存入该文件,当键盘上输入结束时关闭该文件。
#include
main()
{
FILE *fp;
char c;
fp=__________;
do
{
c=getchar();
fputs(c,fp);
}while(c!=EOF);
__________; ;
}
填空题下面程序的功能是:计算1~10之间的奇数之和与偶数之和,请填空。 #include<stdio.h> main() int a,b,c,i; a=c=0; for(i=0;i<=10;i+=2) a+=i; 【10】 ; c+=b; printf("偶数之和=%d/n",a); printf("奇数之和=%d/n",c-11);
填空题下列程序的循环次数是______。 x=2; do x=x*x; while(!x);
填空题以下程序段打开文件后,先利用fseek函数将文件位置指针定位在文件末尾,然后调用ftell函数返回当前文件位置指针的具体位置,从而确定文件长度。请填空。 FILE *myf; long f1; myf=______("test,t","rb"); fseek(myf,0,SEEK_END) ;f1=ftell(myf); fclose(myf); printf("%1d/n",f1);
填空题以下程序中,函数SumColumMin的功能足:求出M行N列二维数组每列元素中的最小值,并计算它们的和值。和值通过形参传回主函数输出。请填空。 #define M 2 #define N 4 void SumColumMm(int a[M][N],int*sum) int i,j,k,s=0; for(i=0;i<N;i++) k=0; for(j=1;j<M;j++) if(a[k][i]>a[j][i]) k=j; s+=______; ______=s; main() int x[M][n])=3;,5,1,4,1,8,3,s; SumC01umMm(______); ptintf("%d/n",s);
填空题有以下程序 #include<stdio.h> main() int i,n[]=0,0,0,0,0; for(i=l;i<=4;i++) n[i]=n[i-1]*3+1;printf("%d",n[i]); 程序运行后的输出结果是______.
填空题下列给定程序中,函数proc()的功能是:在字符串的最前端加入m个*号,形成新串,并且覆盖原串。
例如,用户输入字符串abcd(以回车键结束),然后输入m值为3,则结果为***abcd。
注意:字符串的长度最长允许79。
请修改函数proc()中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdlib.h>
#include<stdio.h)
#include<string.h>
#include<conio.h>
void proc(char str[], int m)
{
char a[80], *p;
int i;
//************found*************
str=p;
for(i=0; i<m; i++)a[i]="*";
do
{ a[i]=*p;
//************found*************
i++;
}
while(*p);
//************found*************
a[i]=0;
strcpy(str, a);
}
void main()
{int m; char str [so];
system("CLS");
printf("/nEnter a string: "); gets(str);
printf("/nThe string: %s/n", str);
printf("/nEnter n(number of *): ");
scanf("%d",
proc(str, m);
printf("/nThe string after inster: %s/n", str);
}