網頁

2016年10月7日 星期五

ex5 C++字串練習





有一亂碼請按程序解密:

cipher="d@414@gMI"

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

30 則留言:

  1. #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;
    }

    回覆刪除
  2. #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;
    }

    回覆刪除
  3. #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;
    }

    回覆刪除
  4. #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;
    }

    回覆刪除
  5. #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;
    }

    回覆刪除
  6. #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;
    }

    回覆刪除
  7. #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;
    }

    回覆刪除
  8. #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;
    }

    回覆刪除
  9. #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;
    }

    回覆刪除
  10. #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;

    }

    回覆刪除
  11. #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;
    }

    回覆刪除
  12. #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;
    }

    回覆刪除
  13. #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;
    }

    回覆刪除
  14. #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;
    }

    回覆刪除
  15. #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;
    }

    回覆刪除
  16. #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;
    }

    回覆刪除
  17. #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;
    }

    回覆刪除
  18. #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;
    }

    回覆刪除
  19. #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;
    }

    回覆刪除
  20. #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;
    }

    回覆刪除
  21. #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;
    }

    回覆刪除
  22. 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;
    }

    回覆刪除
  23. 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;
    }

    回覆刪除
  24. 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;
    }

    回覆刪除
  25. #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; }

    回覆刪除
  26. #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;
    }

    回覆刪除
  27. #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;
    }

    回覆刪除
  28. #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;
    }

    回覆刪除
  29. #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;
    }

    回覆刪除
  30. B10233082 唐偉強2016年12月16日 下午5:20

    #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;
    }

    回覆刪除

HTML 編輯器