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

时间限制: 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

AC情况:

代码《C语言》:

/*程序大体思路:char A[][7]={"apple","banana","orange"};  //A->Bchar B[][5]={"miss","love","kiss"};int  S[]={5,6,6};A[i]如果在字符串中匹配成功 需要替换成 B[i]输入了字符串C[] 后用 "apple","banana","orange" 分别与C[]匹配A[i]匹配成功,则对应的替换成 B[i]为了节省时间 我们不进行替换 而是得到替换的位置时输出"miss","love"或"kiss"然后i跳过"apple","banana"或"orange"的长度 即i+=S[i]那我们还需要在A[i]匹配成功时 再另外保存一个i 先举个例子比如 C="apple orange banana you"则 A[0]="apple"与C匹配后得到匹配的数组下标0    另外记个 0A[1]="banana"与C匹配后得到匹配的数组下标13  另外记个 1A[2]="orange"与C匹配后得到匹配的数组下标6   另外记个 2得到D[2][3]={{0,0},{13,1},{6,2}}以D[0]为主顺序 升序排列  得到 D[2][3]={{0,0},{6,2},{13,1}}然后在输出C的过程中 遇到 0 6 13 我们就知道对应输出 B[0],B[2],B[1].上句话就是:        遇到 D[0][0] D[0][1] D[0][2]我们就知道对应输出 B[D[1][0]],B[D[1][1]],B[D[1][2]]即当我们得到D数组并升序(D数组中存储的匹配的总个数为num):for(i=k=0;C[i];i++){   //输出C字符串if(i==D[0][k]&&k<num)//当i到达 D[0][k]的位置{printf("%s",B[D[1][k]]);//输出B[D[1][k]]i+=S[D[1][k++]];//i加上 "apple","banana"或者"orange"的长度 并且D数组移动到下一个位置}else printf("%c",C[i]);//如果没有到达D的位置 原样输出}
*/
# include <stdio.h>
# define N 201
char A[][7]={"apple","banana","orange"};  //A->B
char B[][5]={"miss","love","kiss"};
int S[]={4,5,5},num,D[2][N];
char C[N];
int BF(char a[],char b[],int c[]);//BF算法 a为主串,b为被检验的串`返回b在a中的第一个下标 若无返回0
void change(int *a,int *b);//交换函数
void Qsort(int A[][N],int left,int right);//快速排序 升序
int main(){int i,j,k;//freopen("AAA.txt","r",stdin);while(gets(C)){for(i=j=num=0;i<3;i++)//用 A[i]匹配C 返回匹配的个数{k=BF(C,A[i],D[0]);//k记录A[i]匹配的个数while(k--)D[1][j++]=i;//D[1]用来存储i}Qsort(D,0,num-1);//以A[0]升序 从下标0---  num-1  一共num个for(i=j=0;C[i];i++){//输出if(i==D[0][j]&&j<num){printf("%s",B[D[1][j]]);i+=S[D[1][j++]];}else printf("%c",C[i]);}printf("\n");//输出回车符}return 0;
}
int BF(char a[],char b[],int c[]){int i=0,j=0,k=num;do{if (b[j]&&a[i++]==b[j])++j;else{b[j]?(i-=j):(c[num++]=i-j);j=0;}}while(a[i-1]);return num-k;
}
void change(int *a,int *b){//交换函数 交换a b的值int c=*a;*a=*b;*b=c;
}
void Qsort(int A[][N],int left,int right)//不需要知道内部 只需要知道是升序就行了
{int i=left,j=right,temp=A[0][left];if(left>=right)  return;while(i!=j){while(A[0][j]>=temp && i<j) j--;while(A[0][i]<=temp && i<j)i++;if(i<j){change(&A[0][i],&A[0][j]);change(&A[1][i],&A[1][j]);}
}change(&A[0][left],&A[0][i]);change(&A[1][left],&A[1][i]);Qsort(A,left,i-1);Qsort(A,i+1,right);
}

代码2:

/*程序大体思路:char A[][7]={"apple","banana","orange"};  //A->Bchar B[][5]={"miss","love","kiss"};int  S[]={5,6,6};A[i]如果在字符串中匹配成功 需要替换成 B[i]输入了字符串C[] 后用 "apple","banana","orange" 分别与C[]匹配A[i]匹配成功,则对应的替换成 B[i]为了节省时间 我们不进行替换 而是得到替换的位置时输出"miss","love"或"kiss"然后i跳过"apple","banana"或"orange"的长度 即i+=S[i]那我们还需要在A[i]匹配成功时 再另外保存一个i 先举个例子比如 C="apple orange banana you"则 A[0]="apple"与C匹配后得到匹配的数组下标0    另外记个 0A[1]="banana"与C匹配后得到匹配的数组下标13  另外记个 1A[2]="orange"与C匹配后得到匹配的数组下标6   另外记个 2得到D[2][3]={{0,0},{13,1},{6,2}}以D[0]为主顺序 升序排列  得到 D[2][3]={{0,0},{6,2},{13,1}}然后在输出C的过程中 遇到 0 6 13 我们就知道对应输出 B[0],B[2],B[1].上句话就是:        遇到 D[0][0] D[0][1] D[0][2]我们就知道对应输出 B[D[1][0]],B[D[1][1]],B[D[1][2]]即当我们得到D数组并升序(D数组中存储的匹配的总个数为num):for(i=k=0;C[i];i++){   //输出C字符串if(i==D[0][k]&&k<num)//当i到达 D[0][k]的位置{printf("%s",B[D[1][k]]);//输出B[D[1][k]]i+=S[D[1][k++]];//i加上 "apple","banana"或者"orange"的长度 并且D数组移动到下一个位置}else printf("%c",C[i]);//如果没有到达D的位置 原样输出}
*/
# include <stdio.h>
# define N 201
char A[][7]={"apple","banana","orange"};  //A->B
char B[][5]={"miss","love","kiss"};
int S[]={4,5,5},D[2][N];
char C[N];
int BF(char a[],char b[],int c[]);//BF算法 a为主串,b为被检验的串`返回b在a中的第一个下标 若无返回0
void change(int *a,int *b);//交换函数
void Qsort(int A[][N],int left,int right);//快速排序 升序
int main(){int i,j,k;//freopen("AAA.txt","r",stdin);while(gets(C)){for(i=j=D[0][0]=0;i<3;i++)//用 A[i]匹配C 返回匹配的个数{k=BF(C,A[i],D[0]);//k记录A[i]匹配的个数while(k--)D[1][++j]=i;//D[1]用来存储i}Qsort(D,1,D[0][0]-1);//以A[0]升序 从下标0---  num-1  一共num个for(i=0,j=1;C[i];i++){//输出if(i==D[0][j]&&j<=D[0][0]){printf("%s",B[D[1][j]]);i+=S[D[1][j++]];}else printf("%c",C[i]);}printf("\n");//输出回车符}return 0;
}
int BF(char a[],char b[],int c[]){int i=0,j=0,k=c[0];do{if (b[j]&&a[i++]==b[j])++j;else{b[j]?(i-=j):(c[++c[0]]=i-j);j=0;}}while(a[i-1]);return c[0]-k;
}
void change(int *a,int *b){//交换函数 交换a b的值int c=*a;*a=*b;*b=c;
}
void Qsort(int A[][N],int left,int right)//不需要知道内部 只需要知道是升序就行了
{int i=left,j=right,temp=A[0][left];if(left>=right)  return;while(i!=j){while(A[0][j]>=temp && i<j) j--;while(A[0][i]<=temp && i<j)i++;if(i<j){change(&A[0][i],&A[0][j]);change(&A[1][i],&A[1][j]);}
}if(i!=left){change(&A[0][left],&A[0][i]);change(&A[1][left],&A[1][i]);}Qsort(A,left,i-1);Qsort(A,i+1,right);
}

刚哥遇到了感情问题(二)--南洋ACM-1294相关推荐

  1. 音频文件 数据库存储_刚哥谈架构 (六) 谈谈数据库架构

    无论是构建什么样的应用,大都离不开数据.而在应用的架构设计中,如何设计数据库,使用什么类型的数据库,就是一个架构师必须了解的.所有的数据库的共同点都是以某种方式存储数据,以某种接口来访问存储的数据.我 ...

  2. 刚哥谈架构 (五)- 推荐给架构师的书单

    刚哥谈架构 (五)- 推荐给架构师的书单 今天收到豆瓣的2019年的总结,发现自己已经在豆瓣渡过10个春秋.今年读了69本书,有很多书非常棒.今天我就给各位架构师,程序员,码农推荐一些我觉得对工作和职 ...

  3. 鸟哥私房菜学习(二)Linux是什么与如何学习

    Linux是什么与如何学习 一.Linux是什么 二.Linux的背景和历史 三.托瓦兹与LInux的发展 Linux虚拟团队的产生和发展 Linux的内核版本 Linux发行版本 四.Linux当前 ...

  4. 跟着刚哥梳理java知识点——多线程(十六)

    创建多线程 第一种方式: ① 继承:继承Thread. ② 重写:重写Thread类的run()方法 ③ 创建:创建一个子类的对象 ④ 调用:调用线程的start()方法,启动此线程,调用run()方 ...

  5. 跟着鬼哥学so改动,二,进行篇

    图/文  听鬼哥说故事 继续上文的内容---------------------------------- 0x1:測试文件的编写 经过上一篇文章的基础学习,如今我们開始进行是用的部分. 既然我们能够 ...

  6. 万哥的数据库笔记(二)关系数据结构及形式化定义

    第二章 关系数据库 2.1 关系数据结构及形式化定义 2.1.1 关系 **域:**一组具有相同数据类型的值的集合 **笛卡尔积:**域上的一种集合运算 D1=导师集合SUPERVISOR={张清玫, ...

  7. 晨哥真有料丨这样的你很掉价!

    哈喽,大家好,这儿是晨哥的CSDN特别专栏. 你的晨哥突然出现. 哈喽,大家好,你的陈哥突然出现. 最近我发现啊大家都很不对劲儿,不对劲儿. 以前都是啊,我好喜欢她,但是我不敢,我不敢告诉她,我就玩儿 ...

  8. 刚子扯谈:微信 今天你打飞机了嘛吗?

    文/刚子 2013年8月5日 开片语:昨日爆爬二坨山后,精神豁然靓丽.虽然晒伤的不算厉害,但是还是有同事关切.说刚子你真黑了.好吧!当然今天咱不扯爬山涉水,也不扯刚子咋就黑了,咱扯今天那个" ...

  9. 《操作系统真象还原》第十四章 ---- 实现文件系统 任务繁多 饭得一口口吃路得一步步走啊(上二)

    文章目录 专栏博客链接 相关查阅博客链接 本书中错误勘误 闲聊时刻 部分缩写熟知 实现文件描述符的原理 文件描述符的介绍 文件描述符与inode的介绍 文件描述符与PCB的描述符数组的介绍 实现文件操 ...

  10. 北海屠龙记------十二

    石破天惊 入手证奇缘 玉钩宛在 神潜守固 誓心聆好语 苓兔皈依 赵霖.王谨正立崖下,闻得呼声惊顾,瞥见对崖似在摇动,耳听山石碎裂之声,不禁大惊,忙纵遁光,往谷外飞去.身刚离地,那长达二里的百丈高崖已经 ...

最新文章

  1. unity项目源码_在Unity中使用protobuf
  2. RaDirect交换器-搭建环境
  3. 一次微信小程序的快速开发体验
  4. asp.net添加删除表格_如何用openpyxl自动化编写Excel电子表格
  5. QPW 用户签到日志表(tf_user_signin_log)
  6. node.js路由控制
  7. php mysql备份类_php MYSQL 数据备份类
  8. VMware vSAN 技术详解 | 资料
  9. php逻辑难是难在sql,[实验吧] 所有web writeup
  10. STC89C52单片机蜂鸣器介绍以及《卡农》歌曲代码示例
  11. 关于印发国家测绘地理信息局2013年立法工作计划的通知
  12. AI美杜莎来袭 · 光点2021
  13. WebRTC之NACK、RTX 在什么时机判断丢包发送NACK请求和RTX丢包重传
  14. 利用Scrapy编写“1024网站种子吞噬爬虫”,送福利
  15. nginx配置简单图片显示
  16. 为什么安装MathType无法复制粘贴
  17. 网易微专业python全栈工程师_Python 的工作已经饱和?那是因为你只会 Python
  18. 【无标题】MobaXterm远程连接服务器跑深度学习
  19. php刷脸登录,PHP实现微信小程序人脸识别刷脸登录功能
  20. 如何正确使用Pandas库提升项目的运行速度?

热门文章

  1. python实现获取毫秒级时间戳
  2. 微博视频发布上传软件使用方法视频、
  3. Office 2007 PIA Demo
  4. Toad 连接 Oracle 数据库
  5. 预览相机——Camera2基本用法
  6. 项目经理跨部门沟通的6个原则
  7. jumpserver执行bash make_migrations.sh报错
  8. 1056. 股票买卖 III
  9. .Net Core中使用UEditor
  10. Unity脚本编译完成检测