c语言利用定义一个函数删除str1字符串中所有在str2字符串中出现的字符,如何做,求解,c语言
1条回答 默认 最新
快乐鹦鹉 2022-12-20 08:56关注对于str1中每个字符串,检查是否出现在str2中
#include <stdio.h> int instr(char *s,char c) { int i=0; while(s[i] != 0) { if(s[i] == c) return 1; i++; } return 0; } int main() { int a[1000],b[1000]; int i=0,j=0; gets(a); gets(b); while(a[i] != 0) { if(instr(b,a[i]) == 0) a[j++] = a[i]; i++; } a[j] = 0; printf("%s",a); }解决评论 打赏 举报 编辑记录无用 1