1663: 串-删除子串
金币值:2
定数:6
时间限制:1.000 s
内存限制:128 M
正确:100
提交:123
正确率:81.30% 命题人:
题目描述
删除主串S中指定开始位置和结束位置的子串 $(1 \le start \le end \le strlen(S))$
【友情提醒】由于 $gets$ 函数存在安全隐患,$gets$ 已从 $C++14$ 及更高版本中移除。可以使用 $\#define \ gets(S) \ fgets(S,sizeof(S),stdin)$作为兼容性宏替换。
【友情提醒】由于 $gets$ 函数存在安全隐患,$gets$ 已从 $C++14$ 及更高版本中移除。可以使用 $\#define \ gets(S) \ fgets(S,sizeof(S),stdin)$作为兼容性宏替换。
测试代码 复制
#include <stdio.h>
#include <string.h>
void strDelete(char s[], int start, int end);
int main(void) {
char s[81];
int start,end;
scanf("%s",s);
scanf("%d %d",&start,&end);
strDelete(s,start,end);
printf("%s",s);
return 0;
}
void strDelete(char s[], int start, int end) {
int i,j;
i=start-1;
j=end;
while(s[j]!='\0') {
}
s[i]='\0';
}
输入格式
第 $1$ 行输入一个主串 $S$;
第 $2$ 行输入一个两个整数 $m$ 和 $n$ 分别表示在主串中删除字串的开始和结束位置。
第 $2$ 行输入一个两个整数 $m$ 和 $n$ 分别表示在主串中删除字串的开始和结束位置。
输出格式
第 $1$ 行输出删除之后的主串 $S$。
输入样例 复制
abcdefg
2 4
输出样例 复制
aefg