zoukankan      html  css  js  c++  java
  • HDU 4730 We Love MOE Girls

    We Love MOE Girls

    Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 68    Accepted Submission(s): 55


    Problem Description
    Chikami Nanako is a girl living in many different parallel worlds. In this problem we talk about one of them.
    In this world, Nanako has a special habit. When talking with others, she always ends each sentence with "nanodesu".
    There are two situations:
    If a sentence ends with "desu", she changes "desu" into "nanodesu", e.g. for "iloveyoudesu", she will say "iloveyounanodesu". Otherwise, she just add "nanodesu" to the end of the original sentence.
    Given an original sentence, what will it sound like aften spoken by Nanako?
     
    Input
    The first line has a number T (T <= 1000) , indicating the number of test cases.
    For each test case, the only line contains a string s, which is the original sentence.
    The length of sentence s will not exceed 100, and the sentence contains lowercase letters from a to z only.
     
    Output
    For every case, you should output "Case #t: " at first, without quotes. The t is the case number starting from 1. Then output which Nanako will say.
     
    Sample Input
    2 ohayougozaimasu daijyoubudesu
     
    Sample Output
    Case #1: ohayougozaimasunanodesu Case #2: daijyoubunanodesu
     
    Source
     
    Recommend
    liuyiding
     
     
    思路:水题
     
    代码:
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <algorithm>
    #include <queue>
    using namespace std;
    int t;
    int length;
    char strr[110];
    char change_str[10] = "nanodesu";
    int main()
    {
        scanf("%d",&t);
        for(int j = 1;j <= t;j ++)
        {
            memset(strr,0,sizeof(strr));
            scanf("%s",strr);
            length = strlen(strr);
            printf("Case #%d: ",j);
            int a = length - 1;int b = length - 2;int c = length - 3;int d = length - 4;
            if(strr[a] == 'u' && strr[b] == 's' && strr[c] == 'e' && strr[d] == 'd')
            {
                for(int i = 0;i < length - 4;i ++)
                    printf("%c",strr[i]);
                printf("%s ",change_str);
            }
            else
            {
                printf("%s%s ",strr,change_str);
            }
        }
        return 0;
    }

  • 相关阅读:
    2016 Multi-University Training Contest 5 ATM Mechine
    2016 Multi-University Training Contest 5 Divide the Sequence
    UVA 10082 WERTYU
    UVA 272 TEX Quotes
    紫书理解
    Codeforces Round #363 (Div. 2) One Bomb
    BestCoder Round #85 hdu5778 abs(素数筛+暴力)
    计算几何模板
    BestCoder Round #85 hdu5777 domino
    BestCoder Round #85 hdu5776 sum
  • 原文地址:https://www.cnblogs.com/GODLIKEING/p/3321617.html
Copyright © 2011-2022 走看看