[Training] 7-19 2020HBU ladder match to knock Ben

7-19 knock Ben

There are micro-blog a self-proclaimed "Big Ben V" guy, ring the bell every day urging code farmers who care of the body to bed early. To add some fun to ring the bell, but also bad to change a few ancient poems. Bad change its method is: go online to search for press "ong" ancient poems rhyme, the end of the sentence the words changed to "knock Ben." For example there is the famous Tang Dynasty poet Li He said: "Xunzhangzhaiju old carving insects, Aria when the curtain hanging jade bow", where "worm" (chong) and "Bow" (gong) are pressed "ong" rhyme. So this poem was worse to "Xunzhangzhaiju old carving insects, Aria when the curtain knocked Ben."

You are given a lot of poetry words, asking you to write a program to automatically press "ong" bad rhyme sentence to "knock Ben."

Input formats:

Firstly, input a positive integer not exceeding N. In a first row 20 of Then N lines of a given Pinyin ancient poetry, the last part is divided into two, comma  , -separated, a full stop  . at the end. Separated by a space between the adjacent word spelling. Title ensure that each character of the alphabet no more than 6 characters, the total length of each line of characters does not exceed 100, and the last part of the at least three words poetry.

Output formats:

For each row verse, it is determined whether pressure "ong" rhyme. That is, the upper and lower end of the two words are "ong" ending. If this pressure is rhyme, then outputs method according to bad surface title change, input with the output format; otherwise the output  Skipped, that is skipping sentence.

Sample input:

5
xun zhang zhai ju lao diao chong, xiao yue dang lian gua yu gong.
tian sheng wo cai bi you yong, qian jin san jin huan fu lai.
xue zhui rou zhi leng wei rong, an xiao chen jing shu wei long.
zuo ye xing chen zuo ye feng, hua lou xi pan gui tang dong.
ren xian gui hua luo, ye jing chun shan kong.

Sample output:

xun zhang zhai ju lao diao chong, xiao yue dang lian qiao ben zhong.
Skipped
xue zhui rou zhi leng wei rong, an xiao chen jing qiao ben zhong.
Skipped
Skipped

Read the entire line, and then determines a comma and full stop in front of the back is not ong

Then later cut into three spelling qiao ben zhong.

 

#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    getchar(); 
    while(n--){
        getline(cin,s);
        int i=0,j=0,flag=0;
        for(i=0;i<s.size()&&s[i]!=',';i++);
        if(s[i-1]=='g'&&s[i-2]=='n'&&s[i-3]=='o')flag=1;
        if(flag&&s[s.size()-2]=='g'&&s[s.size()-3]=='n'&&s[s.size()-4]=='o'){
        	int count=0;
			for(j=s.size()-1;count!=3;j--)if(s[j]==' ')count++;
            s=s.substr(0,j+1);//有bug的比如zhong。
            cout<<s<<" qiao ben zhong.\n";
        }else cout<<"Skipped"<<endl;
    }
    return 0;
}
Published 411 original articles · won praise 138 · views 110 000 +

Guess you like

Origin blog.csdn.net/shiliang97/article/details/104053864