指针 pstr所指字符串的长度为(). char *pstr="\t\"1234\\abcd\n"
A.15
B.14
C.13
D.12
A.15
B.14
C.13
D.12
第2题
成的字符串循环右移n 个。比如原来是"abcdefghi"
如果n=2,移位后应该是"hiabcdefgh"
函数头是这样的:
//pStr是指向以'\0'结尾的字符串的指针
//steps是要求移动的n
void LoopMove ( char * pStr, int steps )
{
//请填充...
}
第3题
函数头是这样的:
//pStr是指向以'\0'结尾的字符串的指针
//steps是要求移动的n
void LoopMove ( char * pStr, int steps )
{
//请填充...
}
第4题
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <conio.h>
include <stdio.h>
include <string.h>
/*************found**************/
int fun (char *s, char *t1, char *t2, char *w)
{
int i; char *p,*r,*a;
strcpy(w,s);
while (*w)
{p=w; r=t1;
/*************found**************/
while (r)
if (*r= =*p) {r++;p++;}
else break;
if (*r= ='\0')
{a=w; r=t2;
/*************found**************/
while (*r){*a=*r;a++;r++}
w+=strlen(t2);
}
else w++;
}
}
main()
{char s[100],t1[100],t2[100],w[100];
clrscr();
printf("\nPlease enter string S: ");
scanf("%s",s);
printf("\nPleaseentersubstring t1: ");
scanf ("%s", t1);
printf("\nPlease enter substring t2: ");
scanf ("%s",t2);
if (strlen(t1)= =strlen(t2))
{
fun (s,t1,t2,w);
printf("\nThe result is : %s\n",w);
}
else printf("Error : strlen(t2)\n");
}
第5题
例如:字符串中原有的字符串为abcde,则调用该函数后,串中的内容变为edcba。
注意;部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
$include<string.h>
include<conio.h>
include<stdio.h>
define N 81
void fun(char*s)
{
int i=0,t,n=strlen(s);
for(;【 】;i++)
{
t=*(s+i);
【 】;
【 】;
}
}
main()
{
char a[N];
clrscr();
printf("Enter a string:");
gets(a);
printf("The original string is:");
puts(a);
fun(a);
printf("\n");
printf("The string after modified:");
puts(a);
}
第6题
A.abcd
B.abba
C.abc
D.abca
第7题
A.abed
B.abba
C.abc
D.abca
第10题
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!