第1题:
以下函数返回a所指数组中最小的值所在的下标值 fun(int *a,int n) { int i,j=0,p; p=j for(i=j;i<n;i++) if(a[i]<a[p])______; return(p);} 在横线处应填入的是
A.i=p
B.a[p]=a[i]
C.p=j
D.p=i
第2题:
有以下程序,其中函数的功能是将多个字符串按字典顺序排序: # include<string.h> void f(char*p[],int n) {char *t; int i,j; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strcmp(p[i],p[j])>0){t=p[i];p[i]=p[j]p[j]=t;} } main() {char *p[5]={"abc","aabdfg","abbd","dcdbe","cd"}; f(p,5); printf("%d\n",strlen(p[1])); } 程序运行后的输出结果是 ______。
A.2
B.3
C.6
D.4
第3题:
pí bèi
wān yán
mǐn ruì
jìng pèi
hé xié
第4题:
有以下程序,其中函数f的功能是将多个字符串按字典顺序排序:#include <stdio, h>#inelude <string, h>void f(char * p[ ] ,int n) char * t;int i,j; for(i=0;i<n-1;i++) for(j=i+1 ;j<n;j ++ ) if(strcmp(p[i], p[j])>0) { t =p[i];p[i] =p[j] ;p[j] =t;}}main( ){ char * p [5] = { "abe"." aabdfg"." abbd"," dcdbe"," cd" }; f(P,5 ); printf("% d\n", strlen(p[1]) );}程序运行后的输出结果是( )。
A.2
B.3
C.60
D.4
第5题:
下列给定程序中fun()函数的功能是:将n个无序整数从小到大排序。
请改正程序中的错误,使它能得出正确的结果。
注意;不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <conio.h>
include <stdio.h>
include <stdlib.h>
fun(int n, int *a)
{ int i,j,p,t;
for (j=0;j<n-1;j++)
{ P=j;
/***************found*******************/
for(i=j+l;i<n-1;i++)
if (a[p]>a[i])
/***************found*******************/
t=i;
if (p!=j)
{t=a[j];a[j]=a[p];a[p]=t;}
}
}
putarr( iht n,int *z)
{int i;
for (i=l;i<=n;i++,z++)
{ printf("%4d",*z);
if (!(i%10)) printf("\n");
} printf ("\n");
}
main ()
{int aa[20]={9,3,0,4,1,2,5,6,8,10,7},n=11;
clrscr();
printf("\n\nBefore sorting %d numbers:\n",n); putarr(n,aa);
fun(n,aa);
printf("\nAfter sorting %d numbers:\n",n);putarr(n,aa);
}
第6题:
有以下程序 #include<string.h> void f(char p[][10],int n)/*字符串从小到大排序*/ { char t[10];int i,j; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strcmp(p[i],p[j])>0) {strcpy(t,p[i]);strcpy(p[i],p[j]);strcpy(p[j],t);} } main() { char p[5][10]={"abc","aabdfg:,"abbd","dcdbe","cd"}; f(p,5); printf("%d\n",strlen(p[0])); } 程序运行后的输出结果是
A.2
B.4
C.6
D.3
第7题:
有以下程序: #include<string.h> void f(char p[][10],int n) /* 字符串从小到大排序 */ {char t[10];int i,j; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strcmp(p[i],p[j])>0{strcpy(t,p[i]);strcpy(p[i],p[j]);strcpy([i],t);} } main() {char p[5][10]={"abc","aabdfg","abbd","dcdbe","cd"; f(p,5); printf("%d\n",strlen(p[0])); } 程序运行后的输出结果( )。
A.2
B.4
C.6
D.3
第8题:
看拼音写词语
jù pà shuāi lǎo pàn duàn xián yí cāo zòng
( ) ( ) ( ) ( ) ( )
fèi xū jǔ sànɡ chàn dǒu jǐn shèn qí qū
( ) ( ) ( ) ( ) ( )
第9题:
以下程序段是函数返回a所指数组中最小的值所在的下标值,请在下划线处填空。
fun(int *a,int n)
{
int i,j=0,p;
p=j;
for(i=j;i<n;i++)
if(a[i]<a[p]) 【 】;
return(p);
}
第10题:
有以下程序fun(int *a,int n) { int i,j=0,p; p=j; for(i=j;i<n;i++) if(a[i]<a[p]) ____; return(p);}在下画线处应填入的是A.i=p B.a[p]=a[i] C.p=j D.p=i