阅读下列函数说明和C函数,将应填入(n)处的字句写在对应栏内。[函数2.1说明]函数strcpy的功能是将字符串str2的内容复制到字符申str1。[函数2.1](1) strcpy (char *slr1, const char *str2){ char * temp;while( * str2!='\0') *cp++ =(2);(3)='\0';return str1;}[函数2.2说明]函数int strcmp(const char *str1, const char *str2)的功能是按字典序比较两个字符串str1和str2的大小。当str1<str2时返回-1,当str1>str2时返回1,否则返回0。[函数2.2]int strcmp(const char *str1, const char *str2){ while( *str1= =* str2) {if(* s1= =(4)) return 0;s1++;(5);}if( *str1<*str2) return -1;return 1;}

阅读下列函数说明和C函数,将应填入(n)处的字句写在对应栏内。

[函数2.1说明]

函数strcpy的功能是将字符串str2的内容复制到字符申str1。

[函数2.1]

(1) strcpy (char *slr1, const char *str2)

{ char * temp;

while( * str2!='\0') *cp++ =(2);

(3)='\0';

return str1;

}

[函数2.2说明]

函数int strcmp(const char *str1, const char *str2)的功能是按字典序比较两个字符串str1和str2的大小。当str1<str2时返回-1,当str1>str2时返回1,否则返回0。

[函数2.2]

int strcmp(const char *str1, const char *str2)

{ while( *str1= =* str2) {

if(* s1= =(4)) return 0;

s1++;

(5);

}

if( *str1<*str2) return -1;

return 1;

}


相关考题:

●试题四阅读下列函数说明和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(ij){temp=A[i]; (2) ; (3) ;}}while(ij);A[a]=A[j];A[j]=x;if(si-1) (4) ;if(j+1t) (5) ;}

●试题一阅读下列函数说明和C代码,把应填入其中n处的字句写在答卷的对应栏内。【函数1.1说明】函数strcpy(char*to,char*from)将字符串from复制到字符串to。【函数1.1】void strcpy(char*to,char*from){while( ( 1 ) );}【函数1.2说明】函数merge(int a[ ],int n,int b[ ],int m,int *c)是将两个从小到大有序数组a和b复制合并出一个有序整数序列c,其中形参n和m分别是数组a和b的元素个数。【函数1.2】void merge(int a[ ],int n,int b[ ],int m,int *c){ int i,j;for(i=j=0;i<n j<m;)*c++=a[i]<b[j]? a[i++]:b[j++];while( (2) )*c++=a[i++];while( (3) )*c++=b[j++];}【函数1.3说明】递归函数sum(int a[ ],int n)的返回值是数组a[ ]的前n个元素之和。【函数1.3】int sum(int a[ ],int n){ if(n>0)return (4) ;else (5) ;}

阅读下列程序说明和C代码,将应填入(n)处的字句写在对应栏内。[说明]函数Printprime(int UpBound)的功能是输出1到UpBound以内的全体素数。[函数2.1]void PrintPrime(int UpBound)printf("2," );for(i=3; i<UpBound; i+ =2) {int k = sqrt(i);for(j=3; j<= k;(1)) /*检查i是否有3到k以入的奇因数*/if((2)) break;fi((3)) printf("%d", i);[函数2.2说明]递归函数invert(int a[],int k),int k)的功能是将数组a中的前k个元素逆置。[函数2.2]void invert(int a[ ], int k){ int t;if ((4)) {invert((5));t=a[0];a[0] =a[k-1];a[k-l]=t;}}

阅读下列函数说明和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);}

阅读以下说明,以及用C++在开发过程中所编写的程序代码,将应填入(n)处的字句写在对应栏内。【说明】在下面函数横线处填上适当的字句,使其输出结果为:构造函数.构造函数.1,25,6析构函数析构函数.【C++代码】include "iostream.h"class AA{ public;AA(int i,int j){A=i; B=j;cout<<"构造函数.\n";}~AA(){(1);}void print();private:int A, B;};void AA∷print(){cout<<A<<","<<B<<endl;}void main(){AA *a1, *a2;(2)=new AA(1, 2);a2=new AA(5, 6);(3);a2->print();(4) a1;(5) a2;}

阅读以下函数说明和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);}

阅读下列程序说明和C程序,将应填入(n)处的字句写在对应栏内。[函数2.1说明]下面程序的功能是计算x和y的最小公倍数。[函数2.1]main(){ int m,n,d,r;seanf("%d %d",m,n);if(m<n) {r=m;m=n;n=r;}(1);while (d%n! =0) (2);printf("%d\n",d);}[函数2.2说明]下述程序接收键盘输入,直到句点“.”时结束。输入的字符被原样输出,但连续的空格输入将转换成一个空格。[函数2.2]include <stdio.h>main(){ char c,preChar='\0';c = getchar();while(c! = '.'){if((3)) putchar(c);else if(preChar! =' ') putchar(c);(4);c=(5);}}

阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。[说明]已知r[1...n]是n个记录的递增有序表,用折半查找法查找关键字为k的记录。若查找失败,则输出“failure",函数返回值为0;否则输出“success”,函数返回值为该记录的序号值。[C函数]int binary search(struct recordtype r[],int n,keytype k){ intmid,low=1,hig=n;while(low<=hig){mid=(1);if(k<r[mid].key) (2);else if(k==r[mid].key){printf("succesS\n");(3);}else (4);}printf("failure\n");(5);}

试题三(共 15 分)阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。