i=0; while (s1[i]==s2[i] && s1[i]!='\0') i++; return (s1[i]-s2[i]);

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/07 11:16:58
i=0; while (s1[i]==s2[i] && s1[i]!='\0') i++; return (s1[i]-s2[i]);

i=0; while (s1[i]==s2[i] && s1[i]!='\0') i++; return (s1[i]-s2[i]);
i=0; while (s1[i]==s2[i] && s1[i]!='\0') i++; return (s1[i]-s2[i]);

i=0; while (s1[i]==s2[i] && s1[i]!='\0') i++; return (s1[i]-s2[i]);
#include <iostream>
using namespace std;
void declare(char *s1,char s2)
{
int i=0,j=0;
while(s1[i]!=0)
{
if(s1[i]!=s2){
if(i!=j) s1[j] = s1[i];
i++;
j++;
}
else{
i++;
}
}
s1[j] = 0;
}
int main()
{//test
char *s1 = new char(12);;
strcpy(s1,"hello,world");
char s2='l';
cout<<s1<<endl;
declare(s1,s2);
cout<<s1<<endl;
return 0;
}
vaela