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

2023-11-09 18:20

本文主要是介绍刚哥遇到了感情问题(二)--南洋ACM-1294,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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

时间限制: 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的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/377815

相关文章

linux生产者,消费者问题

pthread_cond_wait() :用于阻塞当前线程,等待别的线程使用pthread_cond_signal()或pthread_cond_broadcast来唤醒它。 pthread_cond_wait() 必须与pthread_mutex 配套使用。pthread_cond_wait()函数一进入wait状态就会自动release mutex。当其他线程通过pthread

问题:第一次世界大战的起止时间是 #其他#学习方法#微信

问题:第一次世界大战的起止时间是 A.1913 ~1918 年 B.1913 ~1918 年 C.1914 ~1918 年 D.1914 ~1919 年 参考答案如图所示

2024.6.24 IDEA中文乱码问题(服务器 控制台 TOMcat)实测已解决

1.问题产生原因: 1.文件编码不一致:如果文件的编码方式与IDEA设置的编码方式不一致,就会产生乱码。确保文件和IDEA使用相同的编码,通常是UTF-8。2.IDEA设置问题:检查IDEA的全局编码设置和项目编码设置是否正确。3.终端或控制台编码问题:如果你在终端或控制台看到乱码,可能是终端的编码设置问题。确保终端使用的是支持你的文件的编码方式。 2.解决方案: 1.File -> S

vcpkg安装opencv中的特殊问题记录(无法找到opencv_corexd.dll)

我是按照网上的vcpkg安装opencv方法进行的(比如这篇:从0开始在visual studio上安装opencv(超详细,针对小白)),但是中间出现了一些别人没有遇到的问题,虽然原因没有找到,但是本人给出一些暂时的解决办法: 问题1: 我在安装库命令行使用的是 .\vcpkg.exe install opencv 我的电脑是x64,vcpkg在这条命令后默认下载的也是opencv2:x6

问题-windows-VPN不正确关闭导致网页打不开

为什么会发生这类事情呢? 主要原因是关机之前vpn没有关掉导致的。 至于为什么没关掉vpn会导致网页打不开,我猜测是因为vpn建立的链接没被更改。 正确关掉vpn的时候,会把ip链接断掉,如果你不正确关掉,ip链接没有断掉,此时你vpn又是没启动的,没有域名解析,所以就打不开网站。 你可以在打不开网页的时候,把vpn打开,你会发现网络又可以登录了。 方法一 注意:方法一虽然方便,但是可能会有

vue同页面多路由懒加载-及可能存在问题的解决方式

先上图,再解释 图一是多路由页面,图二是路由文件。从图一可以看出每个router-view对应的name都不一样。从图二可以看出层路由对应的组件加载方式要跟图一中的name相对应,并且图二的路由层在跟图一对应的页面中要加上components层,多一个s结尾,里面的的方法名就是图一路由的name值,里面还可以照样用懒加载的方式。 页面上其他的路由在路由文件中也跟图二是一样的写法。 附送可能存在

vue+elementui--$message提示框被dialog遮罩层挡住问题解决

最近碰到一个先执行this.$message提示内容,然后接着弹出dialog带遮罩层弹框。那么问题来了,message提示框会默认被dialog遮罩层挡住,现在就是要解决这个问题。 由于都是弹框,问题肯定是出在z-index比重问题。由于用$message方式是写在js中而不是写在html中所以不是很好直接去改样式。 不过好在message组件中提供了customClass 属性,我们可以利用

Visual Studio中,MSBUild版本问题

假如项目规定了MSBUild版本,那么在安装完Visual Studio后,假如带的MSBUild版本与项目要求的版本不符合要求,那么可以把需要的MSBUild添加到系统中,然后即可使用。步骤如下:            假如项目需要使用V12的MSBUild,而安装的Visual Studio带的MSBUild版本为V14。 ①到MSDN下载V12 MSBUild包,把V12包解压到目录(

YOLO v3 训练速度慢的问题

一天一夜出了两个模型,仅仅迭代了200次   原因:编译之前没有将Makefile 文件里的GPU设置为1,编译的是CPU版本,必须训练慢   解决方案: make clean  vim Makefile make   再次训练 速度快了,5分钟迭代了500次

Pycharm配置conda环境(解决新版本无法识别可执行文件问题)

引言: 很多小伙伴在下载最新版本的pycharm或者更新到最新版本后为项目配置conda环境的时候,发现文件夹目录中无法显示可执行文件(一般为python.exe),以下就是本人遇到该问题后试验和解决该问题的一些方法和思路。 一般遇到该问题的人群有两种,一种是刚入门对pycharm进行conda环境配置的小白(例如我),不熟悉相关环境配置的操作和过程,还有一种是入坑pycharm有段时间的老手