L1-059 Ring the ben clock (20 minutes) [PTA] [Analog]

There is a guy on Weibo who calls himself "Big Ben V", ringing the bell every day to urge code farmers to take care of their bodies and go to bed early. In order to increase the fun of ringing the bell, a few ancient poems will be changed. The way to change it is to search the Internet for ancient poems with "ong" rhymes, and replace the three characters at the end of the sentence with "knock the clock". For example, the poet Li He of the Tang Dynasty famously said: "Looking for chapters and extracting sentences from old carvings and insects, and the moon as the curtain hangs a jade bow", in which "chong" (chong) and "gong" (gong) both suppress the rhyme of "ong". So this line of poem was changed to "Looking for chapters and excerpts the old eagle-worm, and the morning moon as the curtain knocks the clock".

Now I will give you a lot of ancient poems and sentences and ask you to write a program to automatically change the "ong" rhyme sentences into "knock the clock".

Input format:

Enter a positive integer N that does not exceed 20 in the first line. After N lines, each line gives a sentence of ancient poems in Chinese pinyin, divided into upper and lower sentences, , separated by commas  , and ending . with a period  . Use a space to separate the pinyin of two adjacent characters. The title guarantees that the pinyin of each word does not exceed 6 characters, the total length of each line of characters does not exceed 100, and the second half of the poem has at least 3 characters.

Output format:

For each line of verse, judge whether it presses the "ong" rhyme. That is, the words at the end of the upper and lower sentences all end with "ong". If it is the rhyme, it will be output according to the method of the title, the output format is the same as the input; otherwise  Skipped, the sentence will be skipped.

Input sample:

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

Find three spaces forward and output the characters before the third space, and then replace the following with "qiao ben zhong." 

#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f;
priority_queue<int,vector<int>,greater<int>>q;
 
const int mod=10e9+7;

char a[110],b[110];

int main()
{
    int N;
    cin>>N;
    string s[50];
    getchar();
    for(int i=0;i<N;i++)
    {
        getline(cin,s[i]);
    }
    for(int i=0;i<N;i++)
    {
        int len=s[i].size();
        int comma=0,period=0;
        for(int j=0;j<len;j++)
        {
            if(s[i][j]==',')
                comma=j;
            if(s[i][j]=='.')
                period=j;
        }
        if((s[i][comma-1]=='g'&&s[i][comma-2]=='n'&&s[i][comma-3]=='o')&&(s[i][period-1]=='g'&&s[i][period-2]=='n'&&s[i][period-3]=='o'))
        {
            int space=0;
            int num=0;
            for(int j=len-1;j>0;j--)
            {
                if(s[i][j]==' ')
                {
                    num++;
                    if(num==3)
                    {
                        space=j;
                        break;
                    }
                }
            }
            for(int j=0;j<space;j++)
                cout<<s[i][j];
            cout<<" qiao ben zhong."<<endl;
        }
        else
        {
            cout<<"Skipped"<<endl;
        }
    }
    return 0;
}

 

Guess you like

Origin blog.csdn.net/qq_43660826/article/details/109532026