1530. The Seven Percent Solution

来源:互联网 发布:判断素数的c语言程序 编辑:程序博客网 时间:2024/04/30 03:23

http://soj.me/show_problem.php?pid=1530


#include <iostream>
#include <string>
#include <map>
using namespace std;


bool check(char c)
{
if(c==' '||c=='!'||c=='$'||c=='%'||c=='('||c==')'||c=='*')
return true;
return false;
}


int main()
{
map<char,string>m;
m[' ']="%20";
m['!']="%21";
m['$']="%24";
m['%']="%25";
m['(']="%28";
m[')']="%29";
m['*']="%2a";
string str;
while(true)
{
getline(cin,str);
if(str[0]=='#') break;
string s="-";
for(int i=0;i<str.length();i++)
{
if(check(str[i]))
s+=m[str[i]];
else s.push_back(str[i]);
}
for(int i=1;i<s.length();i++)
cout<<s[i];
cout<<endl;
}
return 0;
}