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

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/27 10:41:40
i=0; while (s1[i]==s2[i] && s1[i]!='\0') i++; return (s1[i]-s2[i]);
xRn0M*hx\H `d MQk[9`ֻY7KHQ60 QAHQ)өz#,0O?eN0G٬D:EbN!(ݻzTb T«*3*S,4hڄx+͈;1%g N=+>"nwgTܗve"|\6L kRViڍ_cxg9m?zs$O̫ލ?UE]=8jwENlM

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