置換文字列(交換)

これは、新しい文字列にテキストファイルで指定した文字列に置き換えられます。OJは一時的、ユーザがファイルを読み込み、サポートできない現在のシステムに、我々は行動入力端、終了を示すキーボード入力ファイルの内容からプログラムを書きます。最後の背後にある二つの文字列、必要な置換テキストすべての最初の文字列と2番目の文字列があります。

入力フォーマット:

西安郵政研究所通信は陝西省と工業情報化省の人民政府が共同で設計され、実装されています。研究所は、その壮大な古代の文化で有名な、西安、中国西北にある歴史的な街に位置しています。

終了(終了を示します)

研究所(最初の文字列、必要な置換を有する第二列)

大学(第2列)

出力フォーマット:

西安郵電大学が共同設計し、実装陝西省人民政府が産業と情報Technology.The大学省は西安、中国西北にある歴史的な街に位置しており、その壮大で有名古代の文化。

サンプル入力:

Xi’an Institute of Posts and Telecommunications is co-designed and implemented by the People’s Government of Shaanxi Province and the Ministry of Industry and Information Technology.
The Institute is located in Xi’an, a historic city in Northwest China, famous for its magnificent ancient culture.
end
Institute
University

出力例:

Xi’an University of Posts and Telecommunications is co-designed and implemented by the People’s Government of Shaanxi Province and the Ministry of Industry and Information Technology.The University is located in Xi’an, a historic city in Northwest China, famous for its magnificent ancient culture.
書式#include <iostreamの> 
の#include <CStringの> 
名前空間stdを使用。
INTメイン()
{ 
文字列、B、C、M。
getline(CIN、A)。
(1)一方
{ 
getlineの(CIN、M)。
(m個の== "終了"){もし
	破ります。
}	 
、A + = 'の\ n'; 
+ = M。	
} 
、A + = 'の\ n'; 
getline(CIN、B)。
getline(CIN、C)。
int型が見つかりました。
見出さ= a.find(B)。
(!見出さ= - 1)一方
{ 
a.replace(見出さ、b.size()、C)。
= a.find(B、見出さ+ 1)を求めます。	
} COUT <<。
0を返します。
}

  


おすすめ

転載: www.cnblogs.com/cstdio1/p/11115825.html