若字符串s是“HelloWorld”,则以下JavaScript代码”document.write(s.toLowerCase());”输出结果是()。
A.HELLOWORLD
B.HelloWorld
C.HW
D.helloworld
A.HELLOWORLD
B.HelloWorld
C.HW
D.helloworld
以下程序中函数scmp的功能是返回形参指针s1和s2所指字符串中较小字符串的首地址 #include<stdio.h> #include<string.h> char *scmp(char *s1,char *s2) { if(strcmp(s1,s2)<0) return(s1); else return(s2); } main() { int i;char string[20],str[3][20]; for(i=0;i<3;i++)gets(str[i]); strcpy(string,scmp(str[0],str[1]));/*库函数strcpy对字符串进行复制*/ strcpy(string,scmp(string,str[2])); printf("%s\n",string); } 若运行时依次输入:abcd、abba和abc三个字符串,则输出结果为
A.abcd
B.adba
C.abc
D.abca
请编写函数fun(),该函数的功能是:将M行N列的二维数组中的字符数据,按列的顺序依次放到一个字符串中。
例如,若二维数组中的数据为:
W WWW
S S S S
H H H H
则字符串中的内容应是WSHWSHWSHWSH。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<stdio.h>
define M 3
define N 4
void fun(char (*s)[N],char *b)
{
}
main()
{
char a[100],w[M][N]={{ 'W', 'W', 'W', 'W'},
{'S', 'S', 'S', 'S'},{'H', 'H', 'H', 'H'}};
int i,j;
printf("The matrix:\n");
for(i=0;i<M;i++)
{ for(j=0;j<N;j++)
printf("%3c",w[i][j]);
printf("\n");
}
fun(w,a);
printf("The A string:In");
puts(a);
printf("\n\n");
}
A.若要输出随机第n个字符,则该字符的索引为s[n]
B.索引s[2]和s[-5]的字符相同
C.s[-3]的运行结果是 绿
D.字符 紫 的索引是s[7]或者s[-1]