herrDeng網內搜尋

自訂搜尋

Ads

2016年10月7日 星期五

ex5 C++字串練習





有一亂碼請按程序解密:

cipher="d@414@gMI"

1.'@'->'a'
2. "14"->"這4"
3. 改大寫
4. "DA4"->"不對"
5 'A'->"個"
6. "GMI"->"吉米"

30 則留言:

B10333054 提到...

#include<iostream>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++)
if ('a' <= x[i] && x[i] <= 'z')
x[i] = (char)x[i] - 'a' + 'A';
return x;
}
string str_replace (string x, string y, string z){
int e;
while ((e = x.find(y)) != -1)
x.replace(e, y.length(), z);
return x;
}
int main(){
string x = "d@414@gMI";
cout << "cipher=" << x << endl;
x = str_replace(x, "@", "a");
cout << "cipher=" << x << endl;
x = str_replace(x, "14", "這4");
cout << "cipher=" << x << endl;
x = toUpper(x);
cout << "cipher=" << x << endl;
x = str_replace(x, "DA4", "不對");
cout << "cipher=" << x << endl;
x = str_replace(x, "A", "個");
cout << "cipher=" << x << endl;
x = str_replace(x, "GMI", "吉米");
cout << "cipher="<<x << endl;
system("Pause");
return 0;
}

B10333016 提到...

#include<iostream>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++)
if ('a' <= x[i] && x[i] <= 'z')
x[i] = (char)x[i] - 'a' + 'A';
return x;
}
string str_replace (string x, string y, string z){
int e;
while ((e = x.find(y)) != -1)
x.replace(e, y.length(), z);
return x;
}
int main(){
string x = "d@414@gMI";
cout << "cipher=" << x << endl;
x = str_replace(x, "@", "a");
cout << "cipher=" << x << endl;
x = str_replace(x, "14", "這4");
cout << "cipher=" << x << endl;
x = toUpper(x);
cout << "cipher=" << x << endl;
x = str_replace(x, "DA4", "不對");
cout << "cipher=" << x << endl;
x = str_replace(x, "A", "個");
cout << "cipher=" << x << endl;
x = str_replace(x, "GMI", "吉米");
cout << "cipher="<<x << endl;
system("Pause");
return 0;
}

B10333049 提到...

#include<iostream>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++)
if ('a' <= x[i] && x[i] <= 'z')
x[i] = (char)x[i] - 'a' + 'A';
return x;
}
string str_replace (string x, string y, string z){
int e;
while ((e = x.find(y)) != -1)
x.replace(e, y.length(), z);
return x;
}
int main(){
string x = "d@414@gMI";
cout << "cipher=" << x << endl;
x = str_replace(x, "@", "a");
cout << "cipher=" << x << endl;
x = str_replace(x, "14", "這4");
cout << "cipher=" << x << endl;
x = toUpper(x);
cout << "cipher=" << x << endl;
x = str_replace(x, "DA4", "不對");
cout << "cipher=" << x << endl;
x = str_replace(x, "A", "個");
cout << "cipher=" << x << endl;
x = str_replace(x, "GMI", "吉米");
cout << "cipher="<<x << endl;
system("Pause");
return 0;
}

A10433021 提到...

#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
string toUpper(string x){
int n = x.length();
for (int i = 0; i < n; i++)
if ('a' <= x[i] && x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
return x;
}

string str_replace(string& x, string OLD, string NEW){
int pos;
while ((pos = x.find(OLD)) != -1)
x.replace(pos, OLD.length(), NEW);
return x;
}

int main(){
string x;
getline(cin, x);
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = str_replace(x, "AB", "就是");
cout << x << endl;
x = str_replace(x, "ab", "不能有小寫");
cout << x << endl;
system("pause");
return 0;
}

B10533065 提到...

#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++){
if (x[i] >= 'a'&& x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}
string str_replace(string x, string OLD, string NEW){
int pos;
while ((pos = x.find(OLD)) != -1){
x = x.replace(pos, OLD.length(), NEW);
}
return x;
}
int main(){
string x = "d@414@gMI";
cout << x << endl;
x = str_replace(x, "@", "a");
cout << x << endl;
x = str_replace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = str_replace(x, "DA4", "不對");
cout << x << endl;
x = str_replace(x, "A", "個");
cout << x << endl;
x = str_replace(x, "GMI", "吉米");
cout << x << endl;
system("pause");
return 0;
}

A10433021 提到...

#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;string&gt;
using namespace std;
string toUpper(string x){
int n = x.length();
for (int i = 0; i &lt; n; i++)
if ('a' &lt;= x[i] &amp;&amp; x[i] &lt;= 'z')
x[i] = x[i] - 'a' + 'A';
return x;
}

string str_replace(string&amp; x, string OLD, string NEW){
int pos;
while ((pos = x.find(OLD)) != -1)
x.replace(pos, OLD.length(), NEW);
return x;
}

int main(){
string x;
getline(cin, x);
cout &lt;&lt; x &lt;&lt; endl;
x = toUpper(x);
cout &lt;&lt; x &lt;&lt; endl;
x = str_replace(x, "AB", "&#23601;&#26159;");
cout &lt;&lt; x &lt;&lt; endl;
x = str_replace(x, "ab", "&#19981;&#33021;&#26377;&#23567;&#23531;");
cout &lt;&lt; x &lt;&lt; endl;
system("pause");
return 0;
}

B10533065 提到...

#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++){
if (x[i] >= 'a'&& x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}
string str_replace(string x, string OLD, string NEW){
int pos;
while ((pos = x.find(OLD)) != -1){
x = x.replace(pos, OLD.length(), NEW);
}
return x;
}
int main(){
string x = "d@414@gMI";
cout << x << endl;
x = str_replace(x, "@", "a");
cout << x << endl;
x = str_replace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = str_replace(x, "DA4", "不對");
cout << x << endl;
x = str_replace(x, "A", "個");
cout << x << endl;
x = str_replace(x, "GMI", "吉米");
cout << x << endl;
system("pause");
return 0;
}

B10133186 提到...

#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++) {
if (x[i] >= 'a' &&x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}
string strReplace(string x, string Old, string New){
int pose;
while ((pose = x.find(Old)) != -1)
x.replace(pose,Old.length(),New);
return x;
}
int main()
{
string x;
getline(cin, x);
cout << x << endl;
x = strReplace(x, "@", "a");
cout << x << endl;
x = strReplace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = strReplace(x, "DA4", "不對");
cout << x << endl;
x = strReplace(x, "A", "個");
cout << x << endl;
x = strReplace(x, "GMI", "吉米");
cout << x << endl;
system("Pause");
return 0;
}

B10433092 提到...

#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++){
if (x[i] >= 'a' && x[i] <= 'z')
x[i] = (char)x[i] - 'a' + 'A';
}
return x;
}
string str_replace(string x, string OLD, string NEW){
int pos;
while ((pos = x.find(OLD)) != -1){
x = x.replace(pos, OLD.length(), NEW);
}
return x;
}

int main()
{
string x;
getline(cin, x);
cout << x << endl;
cout << x.length() << endl;
x=str_replace(x, "@", "a");
cout << x << endl;
cout << x.length() << endl;
x = str_replace(x, "14", "這4");
cout << x << endl;
cout << x.length() << endl;
x = toUpper(x);
cout << x << endl;
cout << x.length() << endl;
x = str_replace(x, "DA4", "不對");
cout << x << endl;
cout << x.length() << endl;
x = str_replace(x, "A", "個");
cout << x << endl;
cout << x.length() << endl;
x = str_replace(x, "GMI", "吉米");
cout << x << endl;
cout << x.length() << endl;
system("Pause");
return 0;
}

A10433018 提到...

#include<iostream>
#include<cstdlib>
#include<string>
#include<cstring>
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++){
if (x[i] >= 'a'&& x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}
string strReplace(string x, string Old, string New){
int pose;
while ((pose = x.find(Old)) != -1)
x.replace(pose, Old.length(),New);
return x;
}
int main()
{
string x;
getline(cin, x);
cout << x << endl;

x = strReplace(x, "@", "a");
cout << x << endl;
x = strReplace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = strReplace(x, "DA4", "不對");
cout << x << endl;
x = strReplace(x, "A", "個");
cout << x << endl;
x = strReplace(x, "GMI", "吉米");
cout << x << endl;
system("Pause");
return 0;

}

B10433080 提到...

#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++){
if (x[i] >= 'a'&& x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}

string str_replace(string x, string OLD, string NEW){
int pos;
while ((pos = x.find(OLD)) != -1){
x = x.replace(pos, OLD.length(), NEW);
}
return x;
}
int main()
{
string x;
getline(cin, x);
cout << x << endl;
x = toUpper(x);
cout << x << endl;
cout << x.length() << endl;
x = str_replace(x, "@", "a");
cout << x << endl;
cout << x.length() << endl;
x = str_replace(x, "14", "這4");
cout << x << endl;
cout << x.length() << endl;
x = toUpper(x);
cout << x << endl;
cout << x.length() << endl;
x = str_replace(x, "DA4", "不對");
cout << x << endl;
cout << x.length() << endl;
x = str_replace(x, "A", "個");
cout << x << endl;
cout << x.length() << endl;
x = str_replace(x, "GMI", "吉米");
cout << x << endl;
cout << x.length() << endl;
system("Pause");
return 0;
}

B10433080 提到...

#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;string&gt;
#include &lt;cstring&gt;
using namespace std;
string toUpper(string x){
for (int i = 0; i &lt; x.length(); i++){
if (x[i] &gt;= 'a'&amp;&amp; x[i] &lt;= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}

string str_replace(string x, string OLD, string NEW){
int pos;
while ((pos = x.find(OLD)) != -1){
x = x.replace(pos, OLD.length(), NEW);
}
return x;
}
int main()
{
string x;
getline(cin, x);
cout &lt;&lt; x &lt;&lt; endl;
x = toUpper(x);
cout &lt;&lt; x &lt;&lt; endl;
cout &lt;&lt; x.length() &lt;&lt; endl;
x = str_replace(x, "@", "a");
cout &lt;&lt; x &lt;&lt; endl;
cout &lt;&lt; x.length() &lt;&lt; endl;
x = str_replace(x, "14", "&#36889;4");
cout &lt;&lt; x &lt;&lt; endl;
cout &lt;&lt; x.length() &lt;&lt; endl;
x = toUpper(x);
cout &lt;&lt; x &lt;&lt; endl;
cout &lt;&lt; x.length() &lt;&lt; endl;
x = str_replace(x, "DA4", "&#19981;&#23565;");
cout &lt;&lt; x &lt;&lt; endl;
cout &lt;&lt; x.length() &lt;&lt; endl;
x = str_replace(x, "A", "&#20491;");
cout &lt;&lt; x &lt;&lt; endl;
cout &lt;&lt; x.length() &lt;&lt; endl;
x = str_replace(x, "GMI", "&#21513;&#31859;");
cout &lt;&lt; x &lt;&lt; endl;
cout &lt;&lt; x.length() &lt;&lt; endl;
system("Pause");
return 0;
}

B10433080 提到...

#include &amp;lt;iostream&amp;gt;
#include &amp;lt;cstdlib&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;cstring&amp;gt;
using namespace std;
string toUpper(string x){
for (int i = 0; i &amp;lt; x.length(); i++){
if (x[i] &amp;gt;= 'a'&amp;amp;&amp;amp; x[i] &amp;lt;= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}

string str_replace(string x, string OLD, string NEW){
int pos;
while ((pos = x.find(OLD)) != -1){
x = x.replace(pos, OLD.length(), NEW);
}
return x;
}
int main()
{
string x;
getline(cin, x);
cout &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;
x = toUpper(x);
cout &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; x.length() &amp;lt;&amp;lt; endl;
x = str_replace(x, "@", "a");
cout &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; x.length() &amp;lt;&amp;lt; endl;
x = str_replace(x, "14", "&amp;#36889;4");
cout &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; x.length() &amp;lt;&amp;lt; endl;
x = toUpper(x);
cout &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; x.length() &amp;lt;&amp;lt; endl;
x = str_replace(x, "DA4", "&amp;#19981;&amp;#23565;");
cout &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; x.length() &amp;lt;&amp;lt; endl;
x = str_replace(x, "A", "&amp;#20491;");
cout &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; x.length() &amp;lt;&amp;lt; endl;
x = str_replace(x, "GMI", "&amp;#21513;&amp;#31859;");
cout &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; x.length() &amp;lt;&amp;lt; endl;
system("Pause");
return 0;
}

A10433024 提到...

#include<iostream>
#include<cstdlib>
#include<string>
#include<cstring>
using namespace std;
string toUpper(string x){
int n = x.length();
for (int i = 0; i < n; i++)
if ('a' <= x[i] && x[i] <= 'z')
x[i] = (char)x[i] - 'a' + 'A';
return x;
}
string strReplace(string x, string old, string New){
int pose;
while ((pose = x.find(old)) != -1)
x.replace(pose, old.length(), New);
return x;
}
int main()
{
string x;
getline(cin, x);
cout << x << endl;

x = strReplace(x, "@", "a");
cout << x << endl;
x = strReplace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = strReplace(x, "DA4", "不對");
cout << x << endl;
x = strReplace(x, "A", "個");
cout << x << endl;
x = strReplace(x, "GMI", "吉米");
cout << x << endl;
system("Pause");
return 0;
}

B10233082 提到...

#include
#include
#include
#include
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++) {
if (x[i] >= 'a' &&x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}
string strReplace(string x, string Old, string New){
int pose;
while ((pose = x.find(Old)) != -1)
x.replace(pose,Old.length(),New);
return x;
}
int main()
{
string x;
getline(cin, x);
cout << x << endl;
x = strReplace(x, "@", "a");
cout << x << endl;
x = strReplace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = strReplace(x, "DA4", "不對");
cout << x << endl;
x = strReplace(x, "A", "個");
cout << x << endl;
x = strReplace(x, "GMI", "吉米");
cout << x << endl;
system("Pause");
return 0;
}

B10233073 提到...

#include
#include
#include
#include
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++) {
if (x[i] >= 'a' &&x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}
string strReplace(string x, string Old, string New){
int pose;
while ((pose = x.find(Old)) != -1)
x.replace(pose,Old.length(),New);
return x;
}
int main()
{
string x;
getline(cin, x);
cout << x << endl;
x = strReplace(x, "@", "a");
cout << x << endl;
x = strReplace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = strReplace(x, "DA4", "不對");
cout << x << endl;
x = strReplace(x, "A", "個");
cout << x << endl;
x = strReplace(x, "GMI", "吉米");
cout << x << endl;
system("Pause");
return 0;
}

B10233074 提到...

#include
#include
#include
#include
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++) {
if (x[i] >= 'a' &&x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}
string strReplace(string x, string Old, string New){
int pose;
while ((pose = x.find(Old)) != -1)
x.replace(pose,Old.length(),New);
return x;
}
int main()
{
string x;
getline(cin, x);
cout << x << endl;
x = strReplace(x, "@", "a");
cout << x << endl;
x = strReplace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = strReplace(x, "DA4", "不對");
cout << x << endl;
x = strReplace(x, "A", "個");
cout << x << endl;
x = strReplace(x, "GMI", "吉米");
cout << x << endl;
system("Pause");
return 0;
}

B10233087 提到...

#include
#include
#include
#include
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++) {
if (x[i] >= 'a' &&x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}
string strReplace(string x, string Old, string New){
int pose;
while ((pose = x.find(Old)) != -1)
x.replace(pose,Old.length(),New);
return x;
}
int main()
{
string x;
getline(cin, x);
cout << x << endl;
x = strReplace(x, "@", "a");
cout << x << endl;
x = strReplace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = strReplace(x, "DA4", "不對");
cout << x << endl;
x = strReplace(x, "A", "個");
cout << x << endl;
x = strReplace(x, "GMI", "吉米");
cout << x << endl;
system("Pause");
return 0;
}

B10233077 提到...

#include
#include
#include
#include
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++) {
if (x[i] >= 'a' &&x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}
string strReplace(string x, string Old, string New){
int pose;
while ((pose = x.find(Old)) != -1)
x.replace(pose,Old.length(),New);
return x;
}
int main()
{
string x;
getline(cin, x);
cout << x << endl;
x = strReplace(x, "@", "a");
cout << x << endl;
x = strReplace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = strReplace(x, "DA4", "不對");
cout << x << endl;
x = strReplace(x, "A", "個");
cout << x << endl;
x = strReplace(x, "GMI", "吉米");
cout << x << endl;
system("Pause");
return 0;
}

B10233096 提到...

#include
#include
#include
#include
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++) {
if (x[i] >= 'a' &&x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}
string strReplace(string x, string Old, string New){
int pose;
while ((pose = x.find(Old)) != -1)
x.replace(pose,Old.length(),New);
return x;
}
int main()
{
string x;
getline(cin, x);
cout << x << endl;
x = strReplace(x, "@", "a");
cout << x << endl;
x = strReplace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = strReplace(x, "DA4", "不對");
cout << x << endl;
x = strReplace(x, "A", "個");
cout << x << endl;
x = strReplace(x, "GMI", "吉米");
cout << x << endl;
system("Pause");
return 0;
}

B10233102 提到...

#include
#include
#include
#include
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++) {
if (x[i] >= 'a' &&x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}
string strReplace(string x, string Old, string New){
int pose;
while ((pose = x.find(Old)) != -1)
x.replace(pose,Old.length(),New);
return x;
}
int main()
{
string x;
getline(cin, x);
cout << x << endl;
x = strReplace(x, "@", "a");
cout << x << endl;
x = strReplace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = strReplace(x, "DA4", "不對");
cout << x << endl;
x = strReplace(x, "A", "個");
cout << x << endl;
x = strReplace(x, "GMI", "吉米");
cout << x << endl;
system("Pause");
return 0;
}

匿名 提到...

B10233137
#include
#include
#include
#include
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++)
if ('a' <= x[i] && x[i] <= 'z')
x[i] = (char)x[i] - 'a' + 'A';
return x;
}
string str_replace(string x, string y, string z){
int e;
while ((e = x.find(y)) != -1)
x.replace(e, y.length(), z);
return x;
}
int main(){
string x = "d@414@gMI";
cout << "cipher=" << x << endl;
x = str_replace(x, "@", "a");
cout << "cipher=" << x << endl;
x = str_replace(x, "14", "這4");
cout << "cipher=" << x << endl;
x = toUpper(x);
cout << "cipher=" << x << endl;
x = str_replace(x, "DA4", "不對");
cout << "cipher=" << x << endl;
x = str_replace(x, "A", "個");
cout << "cipher=" << x << endl;
x = str_replace(x, "GMI", "吉米");
cout << "cipher=" << x << endl;
system("Pause");
return 0;
}

匿名 提到...

B10233137
#include
#include
#include
#include
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++)
if ('a' <= x[i] && x[i] <= 'z')
x[i] = (char)x[i] - 'a' + 'A';
return x;
}
string str_replace(string x, string y, string z){
int e;
while ((e = x.find(y)) != -1)
x.replace(e, y.length(), z);
return x;
}
int main(){
string x = "d@414@gMI";
cout << "cipher=" << x << endl;
x = str_replace(x, "@", "a");
cout << "cipher=" << x << endl;
x = str_replace(x, "14", "這4");
cout << "cipher=" << x << endl;
x = toUpper(x);
cout << "cipher=" << x << endl;
x = str_replace(x, "DA4", "不對");
cout << "cipher=" << x << endl;
x = str_replace(x, "A", "個");
cout << "cipher=" << x << endl;
x = str_replace(x, "GMI", "吉米");
cout << "cipher=" << x << endl;
system("Pause");
return 0;
}

匿名 提到...

B10233127
#include
#include
#include
#include
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++)
if ('a' <= x[i] &amp;&amp; x[i] <= 'z')
x[i] = (char)x[i] - 'a' + 'A';
return x;
}
string str_replace(string x, string y, string z){
int e;
while ((e = x.find(y)) != -1)
x.replace(e, y.length(), z);
return x;
}
int main(){
string x = "d@414@gMI";
cout << "cipher=" << x << endl;
x = str_replace(x, "@", "a");
cout << "cipher=" << x << endl;
x = str_replace(x, "14", "&#36889;4");
cout << "cipher=" << x << endl;
x = toUpper(x);
cout << "cipher=" << x << endl;
x = str_replace(x, "DA4", "&#19981;&#23565;");
cout << "cipher=" << x << endl;
x = str_replace(x, "A", "&#20491;");
cout << "cipher=" << x << endl;
x = str_replace(x, "GMI", "&#21513;&#31859;");
cout << "cipher=" << x << endl;
system("Pause");
return 0;
}

B10433011 提到...

#include #include #include #include using namespace std; string toUpper(string x){ int n = x.length(); for (int i = 0; i <n; i++) if ('a' <= x[i] && x[i] <= 'z') x[i] = (char)x[i] - 'a' + 'A'; return x; } string strReplace(string x, string old, string New){ int pose; while ((pose = x.find(old)) != -1) x.replace(pose, old.length(), New); return x; } int main() { string x; getline(cin ,x); cout << x << endl; x = toUpper(x); cout << x << endl; x = strReplace(x,"@", "A"); cout << x << endl; x = strReplace(x, "14", "這4"); cout << x << endl; x = strReplace(x, "DA4", "不對"); cout << x << endl; x = strReplace(x, "A", "個"); cout << x << endl; x = strReplace(x, "GMI", "吉米"); cout << x << endl; system("Pause"); return 0; }

B10233109 提到...

#include
#include
#include
#include
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++) {
if (x[i] >= 'a' &&x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}
string strReplace(string x, string Old, string New){
int pose;
while ((pose = x.find(Old)) != -1)
x.replace(pose,Old.length(),New);
return x;
}
int main()
{
string x;
getline(cin, x);
cout << x << endl;
x = strReplace(x, "@", "a");
cout << x << endl;
x = strReplace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = strReplace(x, "DA4", "不對");
cout << x << endl;
x = strReplace(x, "A", "個");
cout << x << endl;
x = strReplace(x, "GMI", "吉米");
cout << x << endl;
system("Pause");
return 0;
}

B10233095 提到...

#include
#include
#include
#include
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++) {
if (x[i] >= 'a' &&x[i] <= 'z')
x[i] = x[i] - 'a' + 'A';
}
return x;
}
string strReplace(string x, string Old, string New){
int pose;
while ((pose = x.find(Old)) != -1)
x.replace(pose,Old.length(),New);
return x;
}
int main()
{
string x;
getline(cin, x);
cout << x << endl;
x = strReplace(x, "@", "a");
cout << x << endl;
x = strReplace(x, "14", "這4");
cout << x << endl;
x = toUpper(x);
cout << x << endl;
x = strReplace(x, "DA4", "不對");
cout << x << endl;
x = strReplace(x, "A", "個");
cout << x << endl;
x = strReplace(x, "GMI", "吉米");
cout << x << endl;
system("Pause");
return 0;
}

B10433103 提到...

#include<iostream>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++)
if ('a' <= x[i] && x[i] <= 'z')
x[i] = (char)x[i] - 'a' + 'A';
return x;
}
string str_replace(string x, string y, string z){
int a;
while ((a = x.find(y)) != -1)
x.replace(a, y.length(), z);
return x;
}
int main(){
string x = "d@414@gMI";
cout << "cipher=" << x << endl;
x = str_replace(x, "@", "a");
cout << "cipher=" << x << endl;
x = str_replace(x, "14", "這4");
cout << "cipher=" << x << endl;
x = toUpper(x);
cout << "cipher=" << x << endl;
x = str_replace(x, "DA4", "不對");
cout << "cipher=" << x << endl;
x = str_replace(x, "A", "個");
cout << "cipher=" << x << endl;
x = str_replace(x, "GMI", "吉米");
cout << "cipher=" << x << endl;
system("Pause");
return 0;
}

a10433015 提到...

#include<iostream>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++)
if ('a' <= x[i] && x[i] <= 'z')
x[i] = (char)x[i] - 'a' + 'A';
return x;
}
string str_replace (string x, string y, string z){
int e;
while ((e = x.find(y)) != -1)
x.replace(e, y.length(), z);
return x;
}
int main(){
string x = "d@414@gMI";
cout << "cipher=" << x << endl;
x = str_replace(x, "@", "a");
cout << "cipher=" << x << endl;
x = str_replace(x, "14", "這4");
cout << "cipher=" << x << endl;
x = toUpper(x);
cout << "cipher=" << x << endl;
x = str_replace(x, "DA4", "不對");
cout << "cipher=" << x << endl;
x = str_replace(x, "A", "個");
cout << "cipher=" << x << endl;
x = str_replace(x, "GMI", "吉米");
cout << "cipher="<<x << endl;
system("Pause");
return 0;
}

B10233082 唐偉強 提到...

#include
#include
#include
#include
using namespace std;
string toUpper(string x){
for (int i = 0; i < x.length(); i++)
if ('a' <= x[i] && x[i] <= 'z')
x[i] = (char)x[i] - 'a' + 'A';
return x;
}
string str_replace (string x, string y, string z){
int e;
while ((e = x.find(y)) != -1)
x.replace(e, y.length(), z);
return x;
}
int main(){
string x = "d@414@gMI";
cout << "cipher=" << x << endl;
x = str_replace(x, "@", "a");
cout << "cipher=" << x << endl;
x = str_replace(x, "14", "這4");
cout << "cipher=" << x << endl;
x = toUpper(x);
cout << "cipher=" << x << endl;
x = str_replace(x, "DA4", "不對");
cout << "cipher=" << x << endl;
x = str_replace(x, "A", "個");
cout << "cipher=" << x << endl;
x = str_replace(x, "GMI", "吉米");
cout << "cipher="<<x << endl;
system("Pause");
return 0;
}

Related Posts Plugin for WordPress, Blogger...

熱門文章