HDU 2719 The Seven Percent Solution

http://acm.hdu.edu.cn/showproblem.php?pid=2719

按要求处理字符串

View Code
#include <stdio.h>
#include <string.h>
int main()
{
    char s[1100];
    char tab1[30]={' ','!','$','%','(',')','*'};
    char tab2[10][20]={{"%20"},{"%21"},{"%24"},{"%25"},{"%28"},{"%29"},{"%2a"}};
    int len,f;
    int i,j;
    while(gets(s))
    {
        if(s[0]=='#')break;
        len=strlen(s);
        for(i=0;i<len;i++)
        {
            f=1;
            for(j=0;j<7;j++)
                if(s[i]==tab1[j])
                {
                    printf("%s",tab2[j]);
                    f=0;
                }
            if(f)            
                printf("%c",s[i]);
        }
        putchar('\n');
    }
    return 0;
} 
原文地址:https://www.cnblogs.com/xiaohongmao/p/2467219.html