刚哥遇到了感情问题

来源:互联网 发布:网络层次结构 编辑:程序博客网 时间:2024/04/29 13:36

题目:

刚哥遇到了感情问题(二)

时间限制:1000 ms  |  内存限制:65535 KB
难度:1
描述

上一集我们讲到 作为工作室老大的刚哥遇到很多女生的追求,你帮他个挑选了个英语成绩不错的对象。在你的帮助下,刚哥找到了个    英语学霸村    的小花,刚哥对小花的追求并不是那么一帆风顺。

事情是这样的:为了追求小花,刚哥打算给小花写点情书,然而小花却要求刚哥用英文给她写情书,并且要求刚哥不许使用百度翻译,这可难为刚哥了,刚哥自幼就爱国,对西洋文不怎么感冒,幸得健爷的帮助,刚哥成功把中文的情书翻译成了英文的情书,然而问题来了,刚哥写的情书太肉麻,健爷决定把   miss  love  kiss  这三个单词替换成  apple  banana  orange  ,眼看着今晚就要约会了,没有这些肉麻的词,刚哥约会时会不自在的.

你能在今晚10点前帮刚哥把信里面出现这三个单词的地方合理地用  miss  love  kiss  替换吗?刚哥都快急哭了,你就帮帮他吧  O(∩_∩)O~

输入
多组输入

一次输入多行

情书以 thas all 结束
程序 读到文档结束。
输出
帮刚哥把信里面出现这三个单词的地方合理地用 miss love kiss 替换, 原格式输出。
样例输入
Dear Mine: Just for one reason, I banana you so much. Nothing is impossible to a willing mind, banana included. Therefore, day after day, I wonder why, I wonder how, I wonder where you are. Time to go, I want to tell you how much I feel, and how much I banana you. When I think of you, the miles between us disappear. Seeing you will cause me an indescribable thrill, even at the sight of your handwriting will make me tremble. And the wonderful times we shared together shall always remain in my heart. You are my little angel. Just having you close fills me with banana and hope; nothing is impossible by your side. It is only when I nearly lose you that I become fully conscious of how much I value you. Accordingly, I would say, "I banana you" for millions and billions of times, and times and times again. Everything comes and goes, but banana stays. When you need someone, remember that I'd be there. If I were in heaven, I'd write your name on every star for all to see just how much you mean to me. No matter how long the road may be in the future, please cherish every moment we shared together. No matter how many years will pass away, please treasure our banana till the last day. banana is the triumph of imagination over intelligence.thas alli apple youi banana youi orange youthas all
样例输出
Dear Mine: Just for one reason, I love you so much. Nothing is impossible to a willing mind, love included. Therefore, day after day, I wonder why, I wonder how, I wonder where you are. Time to go, I want to tell you how much I feel, and how much I love you. When I think of you, the miles between us disappear. Seeing you will cause me an indescribable thrill, even at the sight of your handwriting will make me tremble. And the wonderful times we shared together shall always remain in my heart. You are my little angel. Just having you close fills me with love and hope; nothing is impossible by your side. It is only when I nearly lose you that I become fully conscious of how much I value you. Accordingly, I would say, "I love you" for millions and billions of times, and times and times again. Everything comes and goes, but love stays. When you need someone, remember that I'd be there. If I were in heaven, I'd write your name on every star for all to see just how much you mean to me. No matter how long the road may be in the future, please cherish every moment we shared together. No matter how many years will pass away, please treasure our love till the last day. love is the triumph of imagination over intelligence.thas alli miss youi love youi kiss youthas all
来源
自创
上传者
1483523635

心得:

第一次写是整个单词考虑替换,设定情况还是一句话只出现一个关键字,结果错的惨不忍睹.....,现在这个是根据ascll码锁定单词进行替换


代码<C语言>:


#include<stdio.h>
#include<string.h>
void print();
char str1[3000];
char str2[10]="thas all";
int main()
{
    while( gets(str1)!=NULL   )
    {


        if(strcmp(str1,str2)==0)
        {
            printf("thas all\n");
        }
        else
        {
            print();
        }
    }
    return 0;
}


void print()
{
    int len= strlen(str1);
    str1[len]='0';
    str1[len+1]='\0';
    int i;
    for(i=0; str1[i]!='\0'; i++)
    {
        if(str1[i]=='0'  )
            printf("\n");
        else if(str1[i]+str1[i+4]==198&&str1[i+3]==108)  //根据ascll码确定单词,如果是apple就先打印miss同时,下标跳到apple后
        {
            printf("miss");
            i=i+4;
        }


        else if(str1[i]+str1[i+5]==195&&str1[i+4]==110)
        {
            printf("love");
            i=i+5;
        }


        else if(str1[i]+str1[i+5]==212&&str1[i+4]==103)
        {
            printf("kiss");
            i=i+5;
        }


        else printf("%c",str1[i]);   //如过都没有匹配,原字母输出
    }
    //printf("thas all\n");
    memset(str1,0,sizeof(0));
    return;
}