有以下程序
#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[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
第1题:
有以下程序,其中函数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
第2题:
有以下程序 #include <stdio.h> #include <stdlib.h> int fun(int n) {int *p; p=(int*)malloc(sizeof(int)); *p=n; return *p; } { int a; a=fun(10); printf("%d\n",a+fun(10)); } 程序的运行结果是______。
A.0
B.10
C.20
D.出错
第3题:
有以下程序,其中函数f的功能是将多个字符串按字典顺序排序 #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
第4题:
有以下程序,其中函数f的功能是将多个字符串按字典顺序排序: #include<string.h> void f(char *p[],int n) {char *t;int i,j; for(i=O;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
第5题:
有以下程序,其中函数f的功能是将多个字符串按字典顺序排序: #include<string.h> voidf(char*p[],intn) { 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"
A.2
B.3
C.6
D.4
第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","aabdog","abbd","dcdbe","cd"}; f(p,5); printf("%d\n",strlen(p[0])); } 程序运行后的输出结果是( )。
A.2
B.4
C.6
D.3