A.苛政猛于虎
B.天将降大任于斯人也,必先苦其心志,劳其筋骨
C.师者,所以传道授业解惑也
D.君子上达,小人下达
第1题
试题三(共 15 分)
阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。
第2题
●试题四
阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
函数QuickSort是在一维数组A[n]上进行快速排序的递归算法。
【函数】
void QuickSort(int A[],int s,int t)
{int i=s,j=t+1,temp;
int x=A[s];
do{
do i++;while (1) ;
do j--;while(A[j]>x);
if(i<j){temp=A[i]; (2) ; (3) ;}
}while(i<j);
A[a]=A[j];A[j]=x;
if(s<i-1) (4) ;
if(j+1<t) (5) ;
}
第3题
●试题二
阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
该程序运行后,输出下面的数字金字塔
【程序】
include<stdio.h>
main ()
{char max,next;
int i;
for(max=′1′;max<=′9′;max++)
{for(i=1;i<=20- (1) ;++i)
printf(" ");
for(next= (2) ;next<= (3) ;next++)
printf("%c",next);
for(next= (4) ;next>= (5) ;next--)
printf("%c",next);
printf("\n");
}
}
第4题
●试题三
阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
函数move(int*a,int n)用于整理数组a[]的前n个元素,使其中小于0的元素移到数组的前端,大于0的元素移到数组的后端,等于0的元素留在数表中间。
令a[0]~a[low-1]小于0(初始为空);a[low]~a[i-1]等于0(初始为空);a[i]~a[high]还未考察,当前考察元素为a[i]。a[high+1]~a[n-1]大于0(初始为空)。
【函数】
move(int*a,int n)
{
int i,low,high,t;
low=i=0;high=n-1;
while((1) )
if(a[i]<0)
{
t=a[i];a[i]=a[low];a[low]=t;
(2) ;i++;
}
else if((3) )
{t=a[i];a[i]=a[high];a[high]=t;
(4) ;
}
else (5) ;
}
第5题
●试题一
阅读下列说明和流程图,将应填入(n)的字句写在答题纸的对应栏内。
【说明】
下列流程图(如图4所示)用泰勒(Taylor)展开式
sinx=x-x3/3!+x5/5!-x7/7!+…+(-1)n×x 2n+1/(2n+1)!+…
【流程图】
图4
计算并打印sinx的近似值。其中用ε(>0)表示误差要求。
第6题
●试题八
阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
以下程序的功能是:从键盘上输入一个字符串,把该字符串中的小写字母转换为大写字母,输出到文件test.txt中,然后从该文件读出字符串并显示出来。
【程序】
#include<stdio.h>
main()
{FILE*fp;
charstr[100];inti=0;
if((fp=fopen("text.txt" (1) ))==NULL)
{printf("can't open this file.\n");exit(0);}
printf("input astring:\n");gest(str);
while(str[i])
{if(str[i]>=′a′ && str[i]<=′z′)
str[i]= (2) ;
fputc(str[i], (3) );
i++;
}
fclose(fp);
fp=fopen("test.txt", (4) );
fgets(str,100,fp);
printf("%s\n",str);
(5) ;
}
第7题
阅读以下函数说明和C语言函数,将应填入(n)处的字句写在答题纸的对应栏内。
【函数2.1说明】
递归函数sum(int a[], int n)的返回值是数组a[]的前n个元素之和。
【函数2.1】
int sum (int a[],int n)
{
if(n>0) return (1);
else (2);
}
【函数2.2说明】
有3个整数,设计函数compare(int a,int b,int c)求其中最大的数。
【函数2.2】
int compare (int a, int b, int c )
{ int temp, max;
(3) a:b;
(4) temp:c;
}
【函数2.3说明】
递归函数dec(int a[],int n)判断数组a[]的前n个元素是否是不递增的。不递增返回 1,否则返回0。
【函数2.3】
int dec(int a[], int n )
{
if(n<=1) return 1;
if(a[0]<a[1]) return 0;
return (5);
}
第8题
阅读下列函数说明和C代码,将应填入(n)处的字句写在对应栏内。
【说明】
函数QuickSort是在一维数组A[n]上进行快速排序的递归算法。
【函数】
void QuickSort(int A[ ],int s,int t)
{ int i=s,j=t+1,temp;
int x=A[s];
do{
do i ++ ;while (1);
do j -- ;while(A[j]>x);
if(i<j){temp=A[i];(2);(3);}
}while(i<j);
A[a] =A[j];A[j] =x;
if(s<i-1) (4);
if(j+1<t) (5);
}
第9题
●试题二
阅读下列程序或函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。
【函数2.1说明】
函数strcmp()是比较两个字符串s和t的大小。若s<t函数返回负数;若s=t函数返回0;若s>t,函数返回正数。
【函数2.1】
int strcmp(char *s,char *t)
{ while(*s && *t && (1) ){
s++;t++;
}
return (2) ;
}
【程序2.2说明】
在n行n列的矩阵中,每行都有最大的数,本程序求这n个最大数中的最小一个。
【程序2.2】
#includestdio.h
#define N 100
int a[N][N];
void main()
{ int row ,col,max,min,n;
/*输入合法n(<100),和输入n×n个整数到数组a的代码略*/
for (row=0;row<n;row++){
for(max=a[row][0],col=1;col<n;col++)
if((3) )max=a[row][col];
if((4) )min=max;
else if((5) )min=max;
}
printf ("The min of max numbers is %d\n",min);
}
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!