题目内容

下面程序的功能是在字符串每个字符间插入一个空格。程序的运行结果如下:Input a string:Howareyou↙Insert results:H o w a r e y o u按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。#include #include #define N 100void Insert(char s[]);int main(){ char str[N]; printf("Input a string:"); gets(str); Insert(str); printf("Insert results:%s\n", str); return 0;}void Insert(char s[]){ char t[N]; int i, j; ____________; for (i=0, j=0; ____________; i++, j++) {________;j++;________; } s[j] = '\0';/* 在字符串s的末尾添加字符串结束标志 */}

A. 第19行:strcpy(t, s)第20行:t[i]!='\0'第22行:s[j] = t[i]第24行:s[j] = ' '
B. 第19行:t=s;第20行:t[i]!='\0'第22行:s[i] = t[j]第24行:s[j] = ' '
C. 第19行:strcpy(t, s)第20行:t[i]='\0'第22行:t[j] = s[i]第24行:s[j] = '\0 '
D. 第19行:strcpy(s, t)第20行:t[i]=='\0'第22行:s[j] = t[i]第24行:s[j] = '0 '

查看答案
更多问题

下面程序的功能是比较用户键盘输入的口令userInput与内设的口令password是否相同。若相同,则输出"Correct password! Welcome to the system...",若userInputpassword"。按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。#include #include int main(){ char password[7] = "secret"; char userInput[81] ; printf("Input Password:"); scanf(_____________); if ( ______________ )printf("Correct password! Welcome to the system...\n"); else if ( ___________________)printf("Invalid password!user inputpassword\n"); return 0;}

A. 第8行:"%s", userInput第9行:strcmp(userInput, password) == 0第11行:strcmp(userInput, password) < 0
B. 第8行:"%c", userInput第9行:strcmp(userInput, password) = 0第11行:strcmp(userInput, password) < 0
C. 第8行:"%s", userInput第9行:userInput==password第11行:userInput D. 第8行:"%c", userInput第9行:strcpy(userInput, password) == 0第11行:strcpy(userInput, password) < 0

下列对字符串的定义中,错误的是

A. char str[7] = "FORTRAN";
B. char str[] = "FORTRAN";
C. char *str = "FORTRAN";
D. char str[] = {'F','O','R','T','R','A','N',0};

以下不能打印字符串cde的代码片段是()

A. char s[]="abcde",*p;p=s;printf("%s",p+2)
B. char s[]="abcde";printf("%s",s+2);
C. char s[]="abcde",*p;p=s+2;printf("%s",p);
D. char s[]="abcde";s+=2;printf("%s",s);

以下sizeof运算的结果不为1的是

A. sizeof('0')
B. sizeof("")
C. sizeof('\x21')
D. sizeof("a")

答案查题题库