题解 | 字符串去特定字符
字符串去特定字符
https://www.nowcoder.com/practice/d5d0450134db4cb994a1b323a35262da
#include<stdio.h>//
#include <string.h>
// Created by 28725 on 2026/3/7.
//
int main(int argc, char *argv[]) {
char word[100];
scanf("%s",word);
char special[2];
scanf("%s",special);
int len = strlen(word);
for (int i=0; i<=len; i++) {
if (word[i] == special[0]) {
for (int j=i; j<=len; j++) {
word[j] = word[j+1];
}
i--;
}
}
printf("%s",word);
}
查看21道真题和解析