herrDeng網內搜尋

自訂搜尋

Ads

2008年10月16日 星期四

replace

replace(str1, str2,i) 程式碼

57 則留言:

匿名 提到...

程式
# include< cstdlib >
# include< iostream >
# include< string >
using namespace std;

int main(int argc, char *argv[])
{
string str1("good");
string str2(",very cool");

cout<<"str1:" << str1 << "\n";
cout<<"str2:" << str2 << "\n";

cout<<"連結"<<"\n";
str2.replace(0,0,str1);
cout << str2 << "\n";


system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

# include < iostream >
# include < string >
using namespace std;

int main()
{
string i;
string str1("Link");
string str2(",Internet Explorer");

cout << "原始字串:\n";
cout << "str1: " << str1 << endl;
cout << "str2: " << str2 << "\n\n";


cout << 連結\n";
str2.replace(0,0, str1);
cout << str2 << endl;
system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

string str1 ("hi");
string str2 ("~ha~ha");
str2.replace(0,0,str1);
cout<< str2 <<"\n";

匿名 提到...

string str1("B9633081");
string str2("劉俊賢");

cout<<" str1:"<< str1<<"\n";
cout<<" str2:"<< str2<<"\n";
cout<<"連結"<<"\n";
str2.replace(0,0,str1);
cout<< str2<<"\n";
system("PAUSE");
return EXIT_SUCCESS;

匿名 提到...

using namespace std;

int main(int argc, char *argv[])
{
string str1("happy");
string str2(",only you");

cout<<" str1:"<< str1<<"\n";
cout<<" str2:"<< str2<<"\n";

cout<<"連結"<<"\n";
str2.replace(0,0, str1);
cout<< str2<<"\n";


system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

# include < iostream >
# include < string >
using namespace std;

int main()
{
string str1("Hello");
string str2(" Kitty");

cout << "原始字串:\n";
cout << "str1: " << str1 << endl;
cout << "str2: " << str2 << "\n\n";

//展示結果 ↓↓↓
cout << "執行的結果:\n";
str2.replace(0,0, str1);// ( 第一個:從第幾個位置接續,第二個:從第幾個開始覆蓋)
cout << str2 << endl;

system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

# include < iostream >
# include < string >
using namespace std;

int main()
{
string str1("standout");
string str2(" perfect");

cout << "原始字串:\n";
cout << "str1: " << str1 << endl;
cout << "str2: " << str2 << "\n\n";

//展示替換
cout << "用str1替換在str2的1個:\n";

str2.replace(0,0,str1);
cout << str2 << endl;


system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

# include < iostream >

# include < string >
using namespace std;

int main()
{
string str1("beautiful");
string str2(" cool");

cout << "原始字串:\n";
cout << "str1: " << str1 << endl;
cout << "str2: " << str2 << "\n\n";

//展示替換
cout << "用str1替換在str2的1個:\n";

str2.replace(0,0,str1);
cout << str2 << endl;


system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

#include < iostream >
#include < string >
using namespace std;

int main()
{
string str1("Miracle ");
string str2("Hope");

cout << "原始字串:\n";
cout << "str1: " << str1 << endl;
cout << "str2: " << str2 << "\n\n";

//展示替換
cout << "用str1替換在str2的1個:\n";

str2.replace(0,0,str1);
cout << str2 << endl;







system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

#include < iostream >
#include < string >
using namespace std;

int main()
{
string str1("special");
string str2("money money");

cout << "原始字串:\n";
cout << "str1: " << str1 << endl;
cout << "str2: " << str2 << "\n\n";

//展示替換
cout << "用str1替換在str2的1個:\n";

str2.replace(0,0,str1);
cout << str2 << endl;







system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

public String stringReplace(String sourceString, String toReplaceString, String replaceString)
{
String returnString = sourceString;
int stringLength = 0;
if(toReplaceString != null)
{
stringLength = toReplaceString.length();
}
if(returnString != null && returnString.length() > stringLength)
{
int max = 0;
String S4 = "";
for(int i = 0; i < sourceString.length(); i++)
{
max = i + toReplaceString.length() > sourceString.length()? sourceString.length():i + stringLength;
String S3 = sourceString.substring(i, max);
if(!S3.equals(toReplaceString))
{
S4 += S3.substring(0,1);
}else{
S4 += replaceString;
i += stringLength -1 ;
}
}
returnString = S4;
}
return returnString;
}

匿名 提到...

char *strrep(char *str1,char *str2,int a)
{
int i,j;
a --;
i = 0;
for ( j =a; str1[j] != '\0'; j++ )
if ( str2[i] != '\0' )
{
str1[j] = str2[i];
i++;
}
else
break;
return str1;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int i,j;
pos --; i = 0;
for ( j = pos; str1[j] != '\0'; j++ )
if ( str2[i] != '\0' )
{
str1[j] = str2[i];
i++;
}
else
break;
return str1;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int r=0,t;


for ( t=pos; str1[t] != '\0'; t++ )
if ( str2[r] != '\0' )
{
str1[t] = str2[r];
r++;
}
else
break;
return str2;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int g=0,z;
for (z=pos; str1[z]!= '\0';z++)
if (str2[g]!='\0')
{
str1[z] = str2[g];
g++;
}
else
break;
return str2;

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int g=0,z;
for (z=pos; str1[z]!= '\0';z++)
if (str2[g]!='\0')
{
str1[z] = str2[g];
g++;
}
else
break;
return str2;

匿名 提到...

char *strrep(char *str1,char *str2,int x)
{
int i,j;
a --;
i = 0;
for ( j =a; str1[j] != '\0'; j++ )
if ( str2[i] != '\0' )
{
str1[j] = str2[i];
i++;
}
else
break;
return str1;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int i,j;
i = 0;
for ( j = pos; str1[j] != '\0'; j++ )
if ( str2[i] != '\0' )
{
str1[j] = str2[i];
i++;
}
else
break;
return str1;
}

匿名 提到...

修改
char *strrep(char *str1,char *str2,int a)
{
int i,j;
i = 0;
for ( j =a; str1[j] != '\0'; j++ )
if ( str2[i] != '\0' )
{
str1[j] = str2[i];
i++;
}
else
break;
return str1;
}

匿名 提到...

string str1("楊");
string str2("富凱");

cout<< "str1:" << str1 << "\n";
cout<< "str2:" << str2 << "\n";

cout<<"連結"<<"\n";
str2.replace(0,0,str1);
cout << str2 << "\n";


system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

char *replace(char *str1,char *str2,int s)
{
int a,b;
a = 0;
for ( b = s; str1[b] != '\0'; b++ )
if ( str2[a] != '\0' )
{
str1[b] = str2[a];
a++;
}
else
break;
return str1;
}

匿名 提到...

char *replace(char *a1,char *a2,int b)
{
int c=0,d;
for (z=b; a1[d]!= '\0';d++)
if (a2[z]!='\0')
{
a1[d] = a2[z];
z++;
}
else
break;
return a2;

匿名 提到...

char *replace(char *a1,char *a2,int z)
{
int b=0,c;
for (c=z; a1[c]!= '\0';c++)
if (a2[b]!='\0')
{
a1[c] = a2[b];
b++;
}
else
break;
return a2;

匿名 提到...

char *strrep(char *str1,char *str2,int X)
{
int i,j;
i = 0;
for ( j =X; str1[j] != '\0'; j++ )
if ( str2[i] != '\0' )
{
str1[j] = str2[i];
i++;
}
else
break;
return str1;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int i,k;
i = 0;
for ( k = pos; str1[k] != '\0'; k++ )
if ( str2[i] != '\0' )
{
str1[k] = str2[i];
i++;
}
else

break;
return str1;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int t,h;
t = 0;
for (h=pos;str1[h]!='\0';h++)
if (str2[t]!='\0')
{

str1[h] = str2[t];
t++;

}
else
break;
return str1;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int z,d;
z=0;
for (d=pos; str1[d] != '\0';d++)
if (str2[z] != '\0')
{
str1[d]=str2[z];
z++;
}
else
break;
return str1;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int a,b;
a=0;
for (b=pos; str1[b]!= '\0';b++)
if (str2[a]!='\0')
{
str1[b] = str2[a];
a++;
}
else
break;
return str2;

匿名 提到...

using namespace std;
char *replace(char *str1,char *str2,int pos)
{
int a,b;
a=0;
for (b=pos; str1[b]!= '\0';b++)
if (str2[a]!='\0')
{
str1[b] = str2[a];
a++;
}
else
break;
return str1;

匿名 提到...

char *replace(char *str1,char *str2,int a)
{
int b,c;
b = 0;
for ( c = a; str1[c] != '\0'; c++ )
if ( str2[b] != '\0' )
{
str1[c] = str2[b];
b++;
}
else
break;
return str1;
}

匿名 提到...

char *replace(char *str1,char *str2,int box)
{
int i,g;
i = 0;
for ( g = box; str1[g] != '\0'; g++ )
if ( str2[i] != '\0' )
{
str1[g] = str2[i];
i++;
}
else
break;
return str1;
}

匿名 提到...

char *strrep(char *str1,char *str2,int x)
{
int i,j;
a --;
i = 0;
for ( j =a; str1[j] != '\0'; j++ )
if ( str2[i] != '\0' )
{
str1[j] = str2[i];
i++;
}
else
break;
return str1;
}

匿名 提到...

# include < iostream >
# include < string >
using namespace std;

int main()
{
string i;
string str1("hi");
string str2(",hello");

cout << "原始字串:\n";
cout << "str1: " << str1 << endl;
cout << "str2: " << str2 << "\n\n";


cout << 連結\n";
str2.replace(0,0, str1);
cout << str2 << endl;
system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

char *replace(char *str1,char *str2,int p)
{
int i,j;

for ( j = p; str1[j] != '\0'; j++ )
if ( str2[i] != '\0' )
{
str1[j] = str2[i];
i++;
}
else
break;
return str1;
}

匿名 提到...

char *strrep(char *str1,char *str2,int x)
{
int i,k;
a --;
i = 0;
for ( k =a; str1[k] != '\0'; k++ )
if ( str2[i] != '\0' )
{
str1[k] = str2[k];
i++;
}
else
break;
return str1;
}

匿名 提到...

string str1 ("hi");
string str2 ("~ha~ha");
str2.replace(0,0,str1);
cout<< str2 <<"\n";

匿名 提到...

char *replace(char *str,char *str1,int pos)
{
int x=0,y;
for(y=pos;str[y]!='\0';y++)
if(str1[x]!='\0')
{
str[y] = str1[x];
x++;
}
else
break;
return str;
}

匿名 提到...

#include < cstdlib >
#include < iostream >
#include < string >
using namespace std;

int main(int argc, char *argv[])
{
string str1("Oh!");
string str2(",you are good!");

cout<<" str1:" << str1<<"\n";
cout<<" str2:" << str2<<"\n";

cout<<"link"<<"\n";
str2.replace(0,0, str1);
cout<< str2<<"\n";


system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int t,g;
t=0;
for (g=pos; str1[g]!= '\0';g++)
if (str2[t]!='\0')
{
str1[g] = str2[t];
t++;
}
else
break;
return str1;
}

匿名 提到...

char *strrep(char *str1,char *str2,int t)
{

int i,j;
i = 0;
for ( j =t; str1[j] != '\0'; j++ )
if ( str2[i] != '\0' )
{
str1[j] = str2[i];
i++;
}

else
break;
return str1;
}

匿名 提到...

string str1("資管二乙");
string str2(" B9633091");

cout << "原字串↓\n";
cout << "First - " << str1 << endl;
cout << "Second - " << str2 << "\n\n";

cout << "What happend?\n";
str2.replace(0,0, str1);
cout << str2 << endl<<"\n";


system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

# include< cstdlib >
# include< iostream >
# include< string >
using namespace std;

int main(int argc, char *argv[])
{
string str1("are you ready?");
string str2("yes i am");

cout<<"str1:" << str1 << "\n";
cout<<"str2:" << str2 << "\n";

cout<<"connect"<<"\n";

str2.replace(0,0,str1);
cout << str2 << "\n";


system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int a,b;
a = 0;
for ( b = pos; str1[b] != '\0'; b++ )
if ( str2[a] != '\0' )
{
str1[b] = str2[a];
a++;
}
else
break;
return str1;
}

匿名 提到...

char *strrep(char *str1,char *str2,int p)
{
int a,b;
a = 0;
for ( b =p; str1[b] != '\0'; b++ )
if ( str2[a] != '\0' )
{
str1[b] = str2[a];
a++;
}
else
break;
return str1;
}

匿名 提到...

char *replace(char *str1,char *str2,int k)
{
int i,j;
i = 0;
for ( j = k; str1[j] != '\0'; j++ )
if ( str2[i] != '\0' )
{
str1[j] = str2[i];
i++;
}
else
break;
return str1;
}

匿名 提到...

char *strrep(char *str1,char *str2,int k)
{
int x,z;
x = 0;
for ( z =k; str1[z] != '\0'; z++ )
if ( str2[x] != '\0' )
{
str1[z] = str2[x];
x++;
}
else
break;
return str1;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int p,q;
p = 0;
for ( q = pos; str1[q] != '\0'; q++ )
if ( str2[p] != '\0' )
{
str1[q] = str2[p];
p++;
}
else
break;
return str1;
}

匿名 提到...

char *strrep(char *str1,char *str2,int a)
{
int i,j;
a --;
i = 0;
for ( j =a; str1[j] != '\0'; j++ )
if ( str2[i] != '\0' )
{
str1[j] = str2[i];
i++;
}
else
break;
return str1;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int g=0,z;
for (z=pos; str1[z]!= '\0';z++)
if (str2[g]!='\0')
{
str1[z] = str2[g];
g++;
}
else
break;
return str2;

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int t,g;
t=0;
for (g=pos; str1[g]!= '\0';g++)
if (str2[t]!='\0')
{
str1[g] = str2[t];
t++;
}
else
break;
return str1;
}

匿名 提到...

# include < iostream >
# include < string >
using namespace std;

int main()
{
string i;
string str1("Link");
string str2(",Internet Explorer");

cout << "原始字串:\n";
cout << "str1: " << str1 << endl;
cout << "str2: " << str2 << "\n\n";


cout << 連結\n";
str2.replace(0,0, str1);
cout << str2 << endl;
system("PAUSE");
return EXIT_SUCCESS;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int z,d;
z=0;
for (d=pos; str1[d] != '\0';d++)
if (str2[z] != '\0')
{
str1[d]=str2[z];
z++;
}
else
break;
return str1;
}

匿名 提到...

char *replace(char *str1,char *str2,int pos)
{
int g=0,z;
for (z=pos; str1[z]!= '\0';z++)
if (str2[g]!='\0')
{
str1[z] = str2[g];
g++;
}
else
break;
return str2;

匿名 提到...

char *strrep(char *str1,char *str2,int x)
{
int i,j;
a --;
i = 0;
for ( j =a; str1[j] != '\0'; j++ )
if ( str2[i] != '\0' )
{
str1[j] = str2[i];
i++; }
else
break;
return str1; }

匿名 提到...

char *replace(char *str1,char *str2,int pos)

{
int t,g;
t=0;
for (g=pos; str1[g]!= '\0';g++)
if (str2[t]!='\0')

{
str1[g] = str2[t];
t++;
}
else
break;
return str1;
}

匿名 提到...

char *replace(char *str,char *str1,int pos)
{
int x=i,j;
for(y=pos;str[j]!='\i';j++)
if(str1[x]!='\i')
{
str[j] = str1[x];
x++;
}
else
break;
return str;
}

匿名 提到...

#include < iostream >
#include < string >
using namespace std;
int main()
{string str1("special");
string str2("money money");
cout << "原始字串:\n";
cout << "str1: " << str1 << endl;
cout << "str2: " << str2 << "\n\n";
//展示替換
cout << "用str1替換在str2的1個:\n";
str2.replace(0,0,str1);
cout << str2 << endl;

Related Posts Plugin for WordPress, Blogger...

熱門文章