XTU_1184 A Love Letter

http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1184

给定原字符串,和需要删掉的字符串集,然后输出删除后的字符串,如果长度变为0,输出LOSER。

考验编码能力  !!

#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
char ss[10][10]={"HATE","SHIT","LV","O","FUCK","UGLY","MM"};
int dit[10]={4,4,2,1,4,4,2};
string s;
string jiesu(string s)
{
    string s1="";
    for(int i=0;i<s.size();i++)
        if(s[i]!='#')
        s1+=s[i];
    return s1;
}
bool solve()
{
    int flag=0;
    for(int i=0;i<7;i++)
    {
        int t=-1;
        t=s.find(ss[i]);
        if(t!=-1)
        {
            flag=1;
            for(int j=t;j<t+dit[i];j++)
            s[j]='#';
        }
    }
    s=jiesu(s);
    return flag;
}
int main()
{
    while(cin>>s)
    {
        while(solve());
        if(s.size()) cout<<s<<endl;
        else cout<<"LOSER\n";
    }
    return 0;
}
时间: 2024-11-06 11:51:27

XTU_1184 A Love Letter的相关文章

17. Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string "23" Output: ["ad", "ae", &q

[USACO 2011 Dec Gold] Threatening Letter【后缀】

Problem 3: Threatening Letter [J. Kuipers, 2002] FJ has had a terrible fight with his neighbor and wants to send him a nasty letter, but wants to remain anonymous. As so many before him have done, he plans to cut out printed letters and paste them on

Letter Combinations of a Phone Number

1. Question 给一个数字字符串,按照电话上各个数字对应的字母,返回该字符串代表的所有可能的字母组合. Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit stri

【leetcode】Letter Combinations of a Phone Number

Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string "23" Outpu

a letter and a number

 a letter and a number描述 we define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, ... f(Z) = 26, f(z) = -26; Give you a letter x and a number y , you should output the result of y+f(x). 输入 On the first line, contains a number T(0<T<=10000).then T lines

leetcode第18题--Letter Combinations of a Phone Number

Problem: Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string "23" Output: ["ad", "ae&

LeetCode: Letter Combinations of a Phone Number [018]

[题目] Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string "23" Output: ["ad", "ae"

Leetcode - Letter Combination Of A Phone Number

Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string "23" Output: ["ad", "ae", &q

【LeetCode】17. Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string "23" Output: ["ad", "ae", &q