1663: 串-删除子串
金币值:2
定数:6
时间限制:1.000 s
内存限制:128 M
正确:38
提交:45
正确率:84.44% 命题人:
题目描述
删除主串S中指定开始位置和结束位置的子串(1<=start<=end<=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)作为兼容性宏替换。
输入格式
第1行输入一个主串S
第2行输入一个两个整数m和n分别表示在主串中删除字串的开始和结束位置
第2行输入一个两个整数m和n分别表示在主串中删除字串的开始和结束位置
输出格式
第1行输出删除之后的主串S
输入样例 复制
abcdefg
2 4
输出样例 复制
aefg
提示
#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'; }