问题
填空题
下面程序的功能是将字符数组a中下标值为偶数的元素从小到大排列,其他元素不变,请填空。
#include<iostream.h>
#include<string.h>
void main( )
char a[ ] ="clanguage", t;
int I ,j, k;
k=strlen(a) ;
for(i=0;i<=k-2;i+=2)
for(j=i+2;j<=k; 9 )
if( 10 )
t=a[i] ;a[i] =a[j] ;a[j] =t;
cout < < a;
cout < < endl;
答案
参考答案:9 j+=2
10 a[i] >=a[j] 或a[i] >a[j]
解析: strlen函数是测试字符串长度的函数,函数的值为字符串中的实际长度,不包括’\0’在内。