HDUOJ 2560 The Seven Percent Solution

#include<iostream>
#include<stdlib.h>
using namespace std;

int main() {
    //第一个循环用于输入,遇到#停止
    while (1) {
        //第二个循环用于单次输入的每个字符的判断
        while (1) {
            char c;
            c = getchar();
            //若遇到换行符,则结束此次输入
            if (c == '
' || c == EOF) {
                cout << endl;
                break;
            }
            //遇到#停止
            if (c == '#') 
                return 0;
            //遇到如下替代
            if (c == ' ') cout << "%20";
            else if (c == '!') cout << "x%21";
            else if (c == '$') cout << "%24";
            else if (c == '%') cout << "%25";
            else if (c == '(') cout << "%28";
            else if (c == ')') cout << "%29";
            else if (c == '*') cout << "%2a";
            //否则直接输出
            else putchar(c);
        }
    }
}
原文地址:https://www.cnblogs.com/DaiShuSs/p/9607506.html