herrDeng網內搜尋
自訂搜尋
Ads
訂閱:
張貼留言 (Atom)
熱門文章
-
url="https://www.twse.com.tw/exchangeReport/STOCK_DAY?response=json&date=20220330&stockNo=2330"
-
教育部為提昇全民資安素養與電腦防護能力,本部於101年9月5日至11月5日舉辦「全民資安素養自我評量」活動,請在活動期間內踴躍上網檢測資訊安全素養認知程度,並有機會參與抽獎,詳情請參閱活動網站(網址: https://isafe.moe.edu.tw/event
-
python pandas對黃金、外匯匯率的爬蟲練習,並使用matplotlib.pyplot的函數plot, scatter做資料視覺化處理,採用numpy的統計函數,分析黃金價格波動與歐元走勢的關聯。
-
Python C C++ 2 pointer速解Leetcode 2337 Move Pieces to Obtain a String 多日Leetcode的問題都可用2-pointer法來解,今日2337. Move Pieces to Obtain a String也不例...
-
你會用C的算子sizeof?
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;
張貼留言