Archlinux
GCC 13.1.1 20230429
点击查看代码
#include<stdio.h>
void squeeze( char s1[], char s2[] )
{
int i, j, k;
for( i=0; s1[i]!='\0'; i++ )
for( j=0; s2[j]!='\0'; j++ )
{
if( s1[i] == s2[j] ){
for( k=i; s1[k]!='\0'; k++ ){
s1[k] = s1[k+1];
}
s1[k-i] = '\0';
}
}
}
int main()
{
char arr1[] = "xdqzs";
char arr2[] = "xqrzc";
squeeze( arr1, arr2 );
printf("%s\n", arr1);
return 0;
}
运行截图:
“xdqzs”与“xqrzc”,输出正确。
小白刚学习C语言,代码质量不高,欢迎评论。
标签:++,s2,s1,char,arr1,字符串,squeeze From: https://www.cnblogs.com/yuwu/p/17574233.html