科大讯飞笔试题
删除字符串的_标志位,例如_ddw_scs_,变成ddwscs
#科大讯飞##笔试题目#
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main(){
char str[100];
gets(str);
//char str[] = { '_', 'H', 'e', '_', 'l', 'l', 'o', '!', '\0' };
printf("字符串长度:%d\n", strlen(str));
int _count = 0;
for (int i = 0; i < strlen(str); i++){
if (str[i] == '_'){
_count++;
for (int j = i + 1; j <= strlen(str) - i + 1; j++){
str[j - 1] = str[j];
}
}
}
//最后没有移动的位置设置为结束符'\0'
str[strlen(str) - _count + 1] = '\0';
printf("修改后的字符串为:%s\n", str);
} #科大讯飞##笔试题目#
爱玛科技公司福利 8人发布
查看9道真题和解析