uestc OJ1846 Angry Grammar Nazi

Description

Your friend is what we can call a grammar nazi. He spends a lot of time on popular internet discussion forums. Unfortunately, he has a bad temper and loses his mind whenever someone incorrigibly befouls the English language, with unrelenting violations of grammatical and ortographic rules.
In order to avoid smashed keyboards,monitors and co ee-cup holders, you advice your friend to momentarily stop reading and count to ten each time he becomes angry, instead of smashing something.
Your friend becomes angry whenever he reads the following words or sequences of words:
-- "u", "ur" instead or "you", "your".
-- "would of", "should of" instead of "would have", "should have".
-- "lol" instead of "haha". In fact he becomes angry even when a word contains "lol"as a substring. (Even if a word contains multiple occurrences of "lol", such as the word "lolol", he will only become angry once.)
You decide to write a computer program that reads sentences one by one, and for each sentence calculates how many times your friend will have uttered a number after reading said sentence. Your friend does not read out loud, so numbers that are part of the input-sentences should not be counted.

Input

The first line of the input consists of a single integer T, the number of test cases. The following T lines each contain one sentence; that is, one or more words separated by space.

0 < T <= 50
A sentence consists of at most 100 characters, including spaces.
A word consists only of lower case letters between a and z, inclusively.
Two adjacent words are separated by exactly one space, and a sentence never has leading or trailing spaces.

Output

For each test case, output how many times your friend have said a number after reading the sentence.

Sample Input

4
u haz lolcats
my car is green
i have a lollipop
u should of lold

Sample Output

20
0
10
30

#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
   int t,cout,k,j;
   char ch[105][105],str[105],lol[4]="lol";
   scanf("%d",&t);getchar();
   while(t--)
   {
       gets(str);
       k=0;j=0; cout=0;
       int len=strlen(str);
       for(int i=0;i<=len;i++)
       if(str[i]>='a'&&str[i]<='z')
            ch[k][j++]=str[i];
        else
        {
            ch[k][j]='\0';k++; j=0;
            while(str[i+1]==' ') i++;
        }
        for(int i=0;i<k;i++)
        if(!strcmp(ch[i],"u")||!strcmp(ch[i],"ur"))
                    cout+=10;
        else if((!strcmp(ch[i],"would")||!strcmp(ch[i],"should"))&&!strcmp(ch[i+1],"of"))
                    { cout+=10; i++; }
        else
        {
            int e=0;
            for(j=0;ch[i][j]!='\0'&&e<3;j++)
            if(ch[i][j]==lol[e]) e++;
            else e=0;
            if(e==3) cout+=10;
        }
        printf("%d\n",cout);
   }
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值