zoj 2932 The Seven Percent So...

zoj 2932 The Seven Percent So...,第1张

zoj 2932 The Seven Percent So...
#include "iostream"#include "string"#include "map"using namespace std;int main(){int i, len;string input, ans;map<char, string>m;m[' '] = "%20", m['!'] = "%21", m['$'] = "%24", m['%'] = "%25",m['('] = "%28", m[')'] = "%29", m['*'] = "%2a";while (1){getline(cin, input);if (input == "#")  break;len = input.length();ans.clear();for (i = 0; i < len; i++){switch(input[i]){case ' ': ans += m[input[i]];break;case '!': ans += m[input[i]];break;case '$': ans += m[input[i]];break;case '%': ans += m[input[i]];break;case '(': ans += m[input[i]];break;case ')': ans += m[input[i]];break;case '*': ans += m[input[i]];break;default: ans += input[i];break;}}cout << ans << endl;}}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4922012.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存