问题

有以下程序

#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

参考答案
您可能感兴趣的试题
  • 有以下程序void f(int n, int *r){ int r1=0;if(n%3==0) r1=n/3;else if(n%5==0) r1=n/5;else f(--n,&r1);*r=r1;
  • 有以下程序main(int argc,char *argv[]){ int n=0,i;for(i=1;i
  • 有以下程序int a=4;int f(int n){ int t=0; static int a=5;if(n%2) {int a=6; t+=a++;}else {int a=7 ;t +=a++
  • 有一个名为 init.txt 的文件,内容如下:#define HDY(A,B) A/B#define PRINT(Y) Printf(y=%d\n,Y)有以下程序#include init.t
  • 有以下程序main( ){ char ch[]=uvwxyz,*pc ;pc =ch; printf(%c\n,*(pc+5));}程序运行后的输出结果是A)zB)0C) 元素 ch[5] 的
  • 有以下程序struct S {int n; int a[20];};void f(struct S *P){ int i,j,t;for(i=0;in-1;i++)for(j=i+1;j