单项选择题
有以下程序
#include
void f(char P[][10],int n)/*字符串从小到大排序*/
{char t[10];int i,j;
for(i=0;iO){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
热门
试题
单项选择题
有以下程序:int f(int b[ ][4]){ int i,j,s=0;for(j=0;j2) i=3-j;s+=b[i][j]; }return s; }main( ){ int a[4][4]={{1,2,3,4},{0,2,4,5},{3,6,9,12},{3,2,1,0}};printf(“%d n”,f(a)); }执行后的输出结果是( )。
A.12
B.11
C.18
D.16
单项选择题
以下程序中函数f( )的功能是将n个字符串按由大到小的顺序进行排序。#include<string.h>void f(char p[ ][10],int n){ char t[20]; int i,j;for(i =O;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 [ ] [ 10 ] = { abc , aabdfg , abbd , dcdbe , cd }; int i;f(p,5); printf( %d n ,strlen(p[O] ) );}程序运行后的输出结果是( )。
A.6
B.4
C.3
D.5