UVA 10115 - Automatic Editing(字符串)

Win10 / Win11 启用 Hyper-V 虚拟机详细教程(图文+命令行全攻略) 摘要:本文详细介绍Windows10/11系统启用Hyper-V虚拟化平台的方法,包含专业版/企业版的图形界面和PowerShell命令行操作,以及家庭版通过脚本强制启用的特殊方案。内容涵盖版本支持对比、操作步骤图解、常见问题解答和性能优化建议,帮助开发者快速搭建虚拟化环境进行多系统测试。附微软官方文档参考链接和详细操作示意图。 阅读详情

Automatic Editing

Source file:autoedit.{c, cpp, java, pas}
Input file:autoedit.in
Output file:autoedit.out

Text-processing tools like awk and sed allow you to automatically perform a sequence of editing operations based on a script. For this problem we consider the specific case in which we want to perform a series of string replacements, within a single line of text, based on a fixed set of rules. Each rule specifies the string to find, and the string to replace it with, as shown below.

RuleFindReplace-by
1.banbab
2.bababe
3.anaany
4.ba bhind the g

To perform the edits for a given line of text, start with the first rule. Replace the first occurrence of the find string within the text by thereplace-by string, then try to perform the same replacement again on the new text. Continue until the find string no longer occurs within the text, and then move on to the next rule. Continue until all the rules have been considered. Note that (1) when searching for a findstring, you always start searching at the beginning of the text, (2) once you have finished using a rule (because the find string no longer occurs) you never use that rule again, and (3) case is significant.

For example, suppose we start with the line

banana boat

and apply these rules. The sequence of transformations is shown below, where occurrences of a find string are underlined and replacements are boldfaced. Note that rule 1 was used twice, then rule 2 was used once, then rule 3 was used zero times, and then rule 4 was used once.

 BeforeAfter
banana boatbabana boat
babana boatbababa boat
bababa boatbeba boat
beba boatbehind the goat

The input contains one or more test cases, followed by a line containing only 0 (zero) that signals the end of the file. Each test case begins with a line containing the number of rules, which will be between 1 and 10. Each rule is specified by a pair of lines, where the first line is the find string and the second line is the replace-by string. Following all the rules is a line containing the text to edit. For each test case, output a line containing the final edited text.

Both find and replace-by strings will be at most 80 characters long. Find strings will contain at least one character, but replace-bystrings may be empty (indicated in the input file by an empty line). During the edit process the text may grow as large as 255 characters, but the final output text will be less than 80 characters long.

The first test case in the sample input below corresponds to the example shown above.

Example input:

4
ban
bab
baba
be
ana
any
ba b
hind the g
banana boat
1
t
sh
toe or top
0

Example output:

behind the goat
shoe or shop

======================================

按题目描述的替换即可,先把前一个规则所有的都替换掉再执行下一个规则


第一次用strstr还不是很熟练……

strstr(str,s)可以找到str中s的首地址(可以得到从s开始后面的所有字符),找不到返回空(NULL)

将str分成三段,strstr得到第二段(要替换的内容)的首地址,把第三段保存起来,然后把第二段替换掉再连上第三段即可


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

char str[333],s1[22][333],s2[22][333];

int main()
{
    int n;
    char *p,temp[333];
    while(~scanf("%d",&n))
    {
        if(n==0) break;
        getchar();
        for(int i=0; i<n; i++)
        {
            gets(s1[i]);
            gets(s2[i]);
        }
        gets(str);
        for(int i=0; i<n; i++)
        {
            p=strstr(str,s1[i]);
            if(p!=NULL)
            {
                strcpy(temp,p+strlen(s1[i]));//保存第三段
                strcpy(p,s2[i]);//替换第二段
                strcpy(p+strlen(s2[i]),temp);//连接第三段
                i--;//继续按这个规则查找
            }
        }
        puts(str);
    }
    return 0;
}


CATIA_DELMIA_V5R2019安装包下载及安装教程破解 CATIA_V5R2019/DELMIA_V5R2019安装包下载及安装教程破解 阅读详情

相关推荐

结合 Conda 手动安装 RepeatMasker

RepeatMasker 是一个广泛使用的生物信息学工具,用于识别和屏蔽(mask)基因组序列中的 重复序列(repeats) 。在使用过程中需要调用重复序列数据库(Repbase 和 Dfam),如果使用Conda安装的话会出现许多问题,因此推荐手动安装。在此记录我手动安装RepeatMasker的流程,希望对各位同学有所帮助。

m0_65437087的博客 2535

c++ 输入cin>> get() getline()

最近终于把三种输入方式搞明白了,记下来。** cin **> char n1[20]; > char n2[20]; > cout<<"Enter your name: "<<endl; > cin>>n1; > cout<<"Enter your school: "<<endl; > cin>>n2; > cout<< "your name is "<<n1<<endl; > cout<<"yo

shenchen_studyC的博客 524

Python爬虫之爬取并下载哔哩哔哩视频

它可以爬取并下载视频文件和音频文件!亲自使用过,太好用了。

2301_80124151的博客 3万+

Automatic Editing

 Automatic Editing UVA 10115 大意: 给一个数字N代表有几组替换方式,将每一个测试的最后一句,以上面给出的替换方式替换 要点: 每成功替换一次,应该从头开始重新匹配 代码: #include #include using namespace std; string rule[15]; string replace[15]; string

baidu_22079207的博客 362

比亚迪开放平台接口实战:车身状态监测与智能车联应用开发

本文详细介绍了如何利用比亚迪开放平台的车身状态接口进行智能车联应用开发。通过核心类BYDAutoBodyworkDevice,开发者可以安全获取车辆VIN、车门车窗状态、蓄电池电压、方向盘转角等实时数据,并利用监听器实现状态实时响应。文章提供了从SDK集成、接口调用到典型应用场景(如远程车况检查、车队管理)的完整实战指南,助力开发者快速构建基于比亚迪车辆数据的创新应用。

weixin_29176179的博客 725

Coursera | 离散数学概论(北大)| quiz答案

Coursera离散数学概论quiz答案Week1:数理逻辑:基本概念Week2:数理逻辑:命题逻辑及形式系统Week3:数理逻辑:谓词逻辑及形式系统Week4:集合论:集合代数   先放下Coursera上找的离散数学部分相关课程:   btw.线上学习拿证书还有很多,MOOC、edm等都可。   博主选了北京大学离散数学概论Discrete Mathematics Generality。Mooc上貌似也有,但是上课时间貌似不如Coursera灵活,Coursera时间自己调度,规定时间上完即可。目前课

小鱼干的博客 4126

UVA10115 - Automatic Editing

问题描述输入一系列的替换规则,然后输入一个字符串,然后在字符串中,寻找相同的字符进行规则转换,直到不能转换后输出。思路学习string类型,将许多步骤简化封装,从而被更好的利用。代码#include <iostream> #include <cstring> #include <cctype> #include <cstdio> #include <string> using namespace s

zfprotectors的博客 251

手把手教你用TJA1145A实现CAN节点智能唤醒(含数据帧过滤技巧)

本文详细介绍了如何使用TJA1145A收发器实现CAN节点的智能唤醒功能,包括数据帧过滤技巧和超低功耗设计。通过硬件级帧过滤和双条件唤醒机制,TJA1145A在保持微安级休眠电流的同时,能对特定报文做出毫秒级响应,显著提升电池供电设备的续航能力。

weixin_28721917的博客 250

uva10115

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1056 10115 - Automatic Editing Time limit: 3.000 seconds Problem E: Automatic Editing Source file: au

ZhouRush 558

告别密码本!用Windows NPS给华为/华三交换机做Radius认证,SSH登录更安全

本文详细介绍了如何利用Windows NPS实现华为/华三交换机的Radius认证,提升SSH登录安全性。通过集中化管理、精细化控制和完整审计追踪,企业可告别传统密码本,大幅提升网络设备管理效率。文章包含NPS服务部署指南、交换机配置详解及调试技巧,助力企业构建安全高效的统一认证体系。

weixin_42549723的博客 419

HTML5网页基础设计——课程介绍专栏

案例: 参考代码: <!doctype html> <html> <head> <meta charset="utf-8"> <title>动手实践</title> <style> *{ margin: 0; padding: 0; font-size:14px; } dd{ width: 461px; height: 145px; margin: -4px; pad.

shengming_tutou的博客 4594

UVAOJ 10115 ——Automatic Editing 模拟

Automatic Editing Source file: autoedit.{c, cpp, java, pas} Input file: autoedit.in Output file: autoedit.out Text-processing tools like awk and sed allow you to aut

BLF2 782

华为OD机试 双机位C卷:微服务的集成测试 (C/C++/Py/Java/JS/Go)

华为OD机试 双机位C卷 :微服务的集成测试 ,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解。华为OD机试 微服务的集成测试 , 华为OD 微服务的集成测试

qq_45776114的博客 2066

UVA 10115 - Automatic Editing(字符串替换问题)

这是一道替换字符串中关键字的题。就像word中用一字符串替换另外一个文本中包含的字符串。 下面代码中,找到被替换串位置后用了4步进行替换: 1、被替换串起始位置之前的字符串复制到临时字符串中; 2、将新字符串复制到临时字符串中; 3、将被替换串结束位置后的字符串复制到临时字符串中; 4、将临时字符串复制到原字符串 #include #include // 该函数实现将字符串

zcube的技术博客 1297

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

Automatic Editing - UVa 10115 字符串处理

Problem E: Automatic Editing Source file: autoedit.{c, cpp, java, pas} Input file: autoedit.in Output file: autoedit.out Text-processing tools like awk and sed allow y

提比的强行AC 841

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

UVa10115_Automatic Editing csdn(小白书字符串专题)

解题报告 题意: 替换字符串,一个单词可重复替换 思路: 这种题都很恶心。 #include #include #include #include using namespace std; char str[1000][1000],ch[1000][1000],sh[1000],str1[1000]; int main() { int n,i,j; while(~

_nplus 1107

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

UVA 10115 Automatic Editing (字符串的替换和查找)

分析:水题,熟悉字符串的find和replace函数便可轻易解决 好久每一1A的题了,UVA的格式要求真是醉了,每次都得调试半天格式 #include #include #include #include #include #include using namespace std; int main() { string f[11],re[11];

战场小包的博客 423

UVa 10115 Automatic Editing (字符串中间替换技巧)

10115 - Automatic Editing Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=1056 Text-processing tools like aw

AC,∑ndless 1446

UVa10115 - Automatic Editing- 字符串(子串替换)-难度2

题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=1056 Problem E: Automatic Editing Source file: autoedit.{c, cpp, java,

Ieyasu的专栏 829

UVA - 10115 Automatic Editing(体现c++STL处理字符串的能力)

Text-processing tools like awk and sed allow you to automatically perform a sequence of editing operations based on a script. For this problem we consider the specific case in which we want to perfor

acm_1361677193的专栏 362

UVA 10115-Automatic Editing(运用字符串函数对字符串进行替换)

Automatic Editing Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Description Problem E: Automatic Editing Source file: autoedit.{c, 

Rocky0429 1631

UVA 10115 (暑假-字符串(2) -F - Automatic Editing)

#include #include int main() { char str[30][300], str1[700], str2[700]; int n; while (scanf("%d", &n) && n != 0) { getchar(); for (int i = 0; i < n*2; i++) gets(str[i]); ge

Bingo 1921

UVA - 10115 Automatic Editing

UVA - 10115 Automatic Editing题目大意:给出 find 字符串和 replace 字符串 以及一段文字,将文字中所有与 find 相等的字符串替换为 replace 字符串。解题思路:strstr( )返回第一个子串的位置,用两个指针把文字截断,分别保存即可。百度了才知道还有 strstr( ) 这种黑科技。注意点: cin 后似乎有一个换行符还在缓冲区,要getchar

Together with keyboard (ノ`Д´)ノ 192

UVa 10115 Automatic Editing

/* coder: ACboy date: 2010-2-16 result: AC description: UVa 10115 Automatic Editing*/#include #include #include #include using namespace std;vector findve;vector replaceve;

个人独立博客http://www.acb0y.cn/ 1445

UVa OJ 10115-Automatic Editing

<br />简单字符串处理:<br />{ Author:wzx961008 Problem:UVa 10115-Automatic Editing Verdict:Accepted Language:PASCAL Run Time:0.008s Submission Date:2011-01-14 13:42:55 } var n,i,tmp:longint; before,after:array[1..10]of string; txt:string;

Chiwin 511

UVA 10115-Automatic Editing

UVA 10115-Automatic Editing#题目大意:替换字符,直到字符串找不到对应子字符串后输出解题思路:利用strcat和strcpy操作#include <stdio.h> #include <string.h> #include <iostream> using namespace std; int find(char *a, char *b, char *c, char *d)

ZeroLH00的博客 424
上一篇: UVA 644 - Immediate Decodability(字符串)
下一篇: UVA 424 - Integer Inquiry(大数加法)
coco430
博客等级 码龄14年 9粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值