填空题请补充函数proc(),该函数的功能是把数组arr中的奇数元素按原来的先后顺序放在原数组后面。
例如,原始数组为“33 67 42 58 25 76 85 16 41 55”,则输出结果为“42 58 76 16 33 67 25 85 41 55”。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define M 10
void proc(int arr[])
{
int i, j=0, k=0;
int bb[M];
for(i=0; i<M; i++)
{
if(______)
bb[k++]=arr[i];
else
arr[j++]=arr[i];
}
for(i=0; i<k; ______)
arr[j]=bb[i];
}
void main()
{
int i;
int arr[M]={33, 67, 42, 58, 25, 76, 85, 16, 41, 55};
system("CLS");
printf("/n***original list***/n");
for(i=0; i<M; i++)
printf("%4d", arr[i]);
proc(arr);
printf("/n***new list***/n");
for(i=0; i<M; i++)
printf("%4d", arr[i]);
}
填空题下面程序调用fun函数动态分配两个整型存储单元,并通过形参传回这两个整型存储单元的地址给 s1和s2,将程序补充完整。
┇
main()
{
int*s1,*s2;
┇
fun({{U}} 【11】 {{/U}});
┇
}
int fun({{U}} 【12】 {{/U}});
{
*p=(int *)malloc(sizeof(int));
*q=(int *)malloc(sizeof(int));
}
填空题以下程序的功能是调用函数fun计算:m=1-2+3-4+…+9-10,并输出结果。请填空。 int fun(int n) int m=0,f=1,i; for(i=1;i<=n;i++) m+=i*f; f= 【11】 ; return m; main() printf("m=%d/n", 【12】 );
填空题将以下程序段写成三目运算表达式:{{U}} {{/U}}。 if(a>b) max=a; else max=b;
填空题在索引查找或分块查找中,首先查找 【2】 ,然后再查找相应的 【3】 ,整个索引查找的平均查找长度等于查找索引表的平均查找长度与查找相应子表的平均查找长度之和。
填空题下列程序的运行结果是{{U}} {{U}} {{/U}} {{/U}}。
main()
{ union EXAMPLE
{ struct
{ int x;int y;}in;
int a;
int b;
} e:
e.a=1;e.b=2;
e.in.x=e.a*e.b;
e.in.y=e.a+e.b;
printf("%d,%d/n",e.in.x,e.in.y);
}
填空题以下程序运行后的输出结果是{{U}} [8] {{/U}}。
main()
{int x, a=1,b=2,c=3,d=4;
x=(a<b)?a:b; x=(x<c)?x:c; x=(d>x)?x:d;
printf("%d/n",x);
}
填空题若有如下结构体说明: struct STRU int a,b;char c:double d; struct STRU *p1,*p2; ; 请填空,以完成对t数组的定义,t数组的每个元素为该结构体类型。 【16】 t[20]
填空题以下函数用来求出数组的最大元素在数组中的下标并存放在k所指的存储单元中。请填空。 #include<conio.h> #include<stdio.h> int fun(int *s,int t,int *k) int i; *k=0; ______ if(s[*k]<s[i])*k=i; return______; main() int a[10]:876,675,896,101,301,401,980,431,451,777,k; fun(a,10,&k); pfintf("%d,%d/n",k,a[k]);
填空题以下程序运行后的输出结果是{{U}} 【16】 {{/U}}。
fun(int a)
{int b=0;static int c=3;
b++;c++;
return(a+b+c);
}
main()
{int i,a=5;
for(i=0;i<3;i++)printf("%d%d",i,fun(a));
printf("/n");
}
填空题程序通过定义学生结构体变量,存储学生的学号、姓名和三门课的成绩。函数fun的功能是:对形参b所指结构体变量中的数据进行修改,并在主函数中输出修改后的数据。
例如,若b所指变量t中的学号、姓名和三门课的成绩依次是:10002、“ZhangQi”、93、85、87,修改后输出t中的数据应为:10004、“LiJie”、93、85、87。
请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<string.h>
struct student{
long sno;
char name[10];
float score[3];
};
void fun(struct student *b)
{
/**********found**********/
b ______=10004;
/**********found**********/
strcpy(b ______, "LiJie");
}
main()
{struct student t=(10002, "ZhangQi", 93, 85, 87};
int i;
printf("/n/nThe original data:/n");
printf("/nNo:%ld Name:%s/nScores:", t.sno, t.name);
for(i=0; i<3; i++)
printf("%6.2f", t.score[i]);
printf("/n");
/**********found**********/
fun(______);
printf("/nThe data after modified:/n:);
printf("/nNo:%ld Name:%s/nScores:", t.sno, t.name);
for(i=0; i<3; i++)
printf("%6.2f", t.score[i]);
printf("/n");
}
填空题在64位高档微机中,CPU能同时处理【 】个字节的二进制数据。
填空题fun函数的功能是:首先对a所指的N行N列的矩阵,找出各行中的最大数,再求这N个最大值中最小的那个数并作为函数值返回。请填空。 #include <stdio.h> #define N 100 int fun(int(*a)[N]) int row,col,max,min; for(row=0;row<N;row++) for(max=a[row] [0],col=1;col<N;col++) if(______)max=a[row][col]; if(row==0)min=max; else if(______)min=max; return min;
填空题有以下程序:
void fun(int *a, int i, int j)
{ int t;
if(i<j)
{ t=a[i]; a[i]=a[j]; a[j]=t;
i++ ;j--;
fun(a, i, j);
}
}
main()
{ int x[]=(2, 6, 1, 8), i;
fun(x, 0, 3);
for(i=0; i<4; i++)printf("% 2d", x[i]);
}
程序运行后的输出结果是{{U}} 【7】 {{/U}}。
填空题以下是一个投标公司中标评分统计程序,数组r存有9个评委的打分,统计时,去掉其中的1个最高分与1个最低分,其他7个分数的平均分即是最后得分,请把程序补充完整。
#include<stdio.h>
int main()
{
float r[9]={8.9, 7.6, 9.1, 8.5, 8.6, 8.3, 9.0, 8.4, 8.7};
float sum, ave, max, min;
int i;
______;
for(i=0; i<9; i++)
sum+=______;
max=min=r[0];
for(i=1; i<9; i++)
{
if(______)
max=r[i];
if(min>r[i])
min=r[i];
}
ave=______;
printf("Average=%.2f/n", ave);
return 0;
}
填空题下列给定程序中,函数proc()的功能是:从低位开始取出长整型变量s中奇数位上的数,依次构成一个新数放在t中。例如,当s中的数为123456789时,t中的数为13579。
请修改程序中的错误,使它能得到正确结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
//****found****
int proc(long s,long*t)
{
long s1=10;
*t=s%10;
while(s>0)
{
//****found****
s=s%100;
*t=s%10*s1+*t;
s1=s1*10;
}
}
void main()
long s,t;
system("CLS");
printf("/nPlease enter s:");
scanf("%1d",
proc(s,
printf("The result is:%1d/n",t);
填空题请在以下程序第一行的下划线处填写适当内容,使程序能正确运行。 ______(double,double); main() double x,y; scanf("%1f%1f", printf("%1f/n",max(x,y)); double max(double a,double B) return(a>b ? a:b);
填空题软件工程三要素是方法、工具和过程,其中,______支持软件开发的各个环节的控制和管理。
填空题媒体在计算机领域中的含义,是指存储信息的实体和{{U}} 【4】 {{/U}}。
填空题以下程序的功能是:通过函数func输入字符并统计输入字符的个数。输入时用字符@作为输入结
束标志。请填空。
#include
long 【 】 ;/* 函数说明语句 */
main()
{long n;
n=func();printf("n=%1d\n",n);
}
long func()
{ long m;
for(m=0;getchar()!=@;【 】);
return m;
}
