A - The Hardest Problem Ever(字符串模拟题)

拿捏几道经典的字符串模拟问题 遍历整个字符串paragraph,用一个word去记录每次遇到的字母,只要是正常的字母我们就添加到word上面,如果遇到了空格或者标点了就说明我们这个单词记录完毕了,在单词列表里用find去查询此时记录的word,如果没找到说明可以把它记在map里面,然后每次做完这个判断就把word置为“”,用来进行下一个单词的组装。我发现这种字符串的问题其实写起来很麻烦,可能思路不难多少都能想到一些,主要就是代码的处理,细节问题。太考验代码编写的能力了。找到开头连续的0,找到结尾连续的0,再找中间连续的最大0。 阅读详情

Description

Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. This cipher was so incredibly sound, that no one could figure it out without knowing how it worked.       

You are a sub captain of Caesar's army. It is your job to decipher the messages sent by Caesar and provide to your general. The code is simple. For each letter in a plaintext message, you shift it five places to the right to create the secure message (i.e., if the letter is 'A', the cipher text would be 'F'). Since you are creating plain text out of Caesar's messages, you will do the opposite:       


Cipher text
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Plain text
V W X Y Z A B C D E F G H I J K L M N O P Q R S T U

Only letters are shifted in this cipher. Any non-alphabetical character should remain the same, and all alphabetical characters will be upper case.      

Input

Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets. All characters will be uppercase.       


A single data set has 3 components:       

  1. Start line - A single line, "START"
  2. Cipher message - A single line containing from one to two hundred characters, inclusive, comprising a single message from Caesar
  3. End line - A single line, "END"

Following the final data set will be a single line, "ENDOFINPUT".       

Output

For each data set, there will be exactly one line of output. This is the original message by Caesar.      
 
题目看上去很烦,但是大概意思就是密码翻译,输入一个字母,然后输出时就相当于解密,而秘钥就是把这个字母向左移动5个单位(-5),但是要注意A~E的字母,它们移动的时候是(+21);
最后,注意输入输出格式;
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(){
	int i,j,k;
	char s[500],a[250],c;
	while(scanf("%s",a)!=EOF && strlen(a)<6){
		//要注意加上getchar();因为读入了字符串了; 
		getchar();
		//因为一开始读入的是Start这个字符串,所以要读入其他密文的话,采用一个一个字符读入,然后如果是换行符的话,那么就跳出循环break; 
		if(a[0]=='S'){
			k=0;
			while(c=getchar()){
				if('A'<=c&&c<='E') s[k++]=c+21;
				else if(c>'E'&&c<='Z') s[k++]=c-5;
				else if(c=='\n') break;
				else 	s[k++]=c;
			}
		}
		else {
			s[k]='\0';		//别忘了这一步; 
			puts(s);
		}
		if(strcmp(a,"ENDOFINPUT")==0) break;
	}
}

 
3DMax马克杯制作教程 01 在前视图创建一个【圆柱体】,设置参数,长度为32,高度为82;高度分段12、边数为16;如图所示。 02 点击鼠标右键,把圆柱体转换为可编辑多边形,如图所示。 03 在修改面板中,选择【多边形】层级,在视图中选择所示的面,使用缩放工具稍微缩小一点,如图所示。 04 点击【插入设置】,如图所示。 设置插入数量为2.5mm。 05 点击【挤出设置】,如图所示。 ... 阅读详情

相关推荐

告别实车测试:手把手教你用Vector VT平台搭建OBC/DCDC的HIL测试台架

本文详细介绍了如何利用Vector VT平台搭建新能源汽车OBC/DCDC的HIL测试台架,涵盖硬件选型、模型部署到自动化测试的全流程。通过HIL仿真测试技术,工程师可以高效验证动力域关键部件,大幅缩短开发周期并降低成本,特别适合新能源汽车三电系统的开发验证。

weixin_42659194的博客 340

The Hardest Problem Ever

The Hardest Problem Ever (有史以来最难的问题) Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 3 Accepted Submission(s) : ...

hh的博客 484

SAP S4 MM模块自动记账全流程解析:从评估范围到科目分组的实战配置

本文深入解析SAP S4 MM模块自动记账的全流程,从核心概念评估范围与评估控制入手,详细阐述了评估类、科目分组等关键配置的逻辑关系。通过实战配置步骤,指导如何建立从物料移动(如收货、发料)到自动生成准确财务凭证的完整体系,确保库存价值与总账实时同步,为企业构建可靠的财务业务一体化基石。

weixin_29313547的博客 424

acm.小节

Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ...

weixin_44018261的博客 317

STM32F407 BootLoader实战:从零搭建到OTA升级(附完整源码)

本文详细介绍了为STM32F407微控制器从零搭建BootLoader并实现稳定OTA升级的完整实战指南。内容涵盖Flash分区规划、链接脚本配置、核心跳转逻辑、中断向量表重定向、可靠的升级流程设计,并深入探讨了双备份与回滚机制以提升工业级可靠性。文章提供了可直接使用的代码框架,并分享了关键调试技巧,帮助开发者快速掌握STM32远程固件更新技术。

weixin_29192211的博客 442

新手必看:手把手教你如何通过Github提交CVE漏洞(附完整截图流程)

本文为安全研究新手提供了一份详尽的CVE漏洞提交实战指南。文章重点介绍了如何通过Github平台,从漏洞发现、验证、撰写专业报告到最终提交CVE申请的全流程,并附有完整的截图和沟通模板,帮助初学者迈出负责任漏洞披露的第一步。

ttt77的博客 1253

Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was ke

Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. Thi...

qq_40834200的博客 1238

嵌入式NTC温度解算库:Steinhart-Hart定点实现与硬件解耦设计

NTC热敏电阻是嵌入式系统中最常用的模拟温度传感器,其阻值-温度关系高度非线性,需依赖Steinhart-Hart方程实现高精度转换。该方程通过三参数对数多项式建模,理论上可将误差控制在±0.1°C以内,但直接移植到MCU面临浮点开销大、定点溢出、系数精度损失等工程瓶颈。为此,归一化处理(ln(R/R₂₅))、Q24.8定点运算、查表+插值对数计算等优化技术成为资源受限场景下的关键技术路径。其核心价值在于将ADC采样与温度解算彻底解耦,适配各类HAL/裸机/RTOS环境,广泛应用于电池管理、工业PLC、Io

weixin_35756624的博客 647

杭电ACM1001题

Problem Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of t

若木的博客 1133

电商数据采集实战——多平台价格监控、比价分析与智能告警系统

在电商竞争日益激烈的今天,价格监控与比价分析已成为品牌商、渠道商和消费者的核心需求。对于品牌商而言,需要监控各渠道售价是否低于指导价(破价监控);对于消费者而言,希望在最佳时机以最低价购入心仪商品;对于数据分析师而言,价格波动数据是洞察市场趋势的金矿。然而,电商数据采集面临三大核心挑战:本文将基于 Python + Scrapy + Playwright + Redis + ClickHouse 技术栈,构建一套完整的电商价格监控与比价系统。架构分层说明:电商平台的反爬手段层出不穷,采集系统必须具备多层次的

从事移动开发八年,csdn博客专家,阿里云特邀专家,华为云云享专家,高级网络信息安全工程师,大数据工程师(高级),python技术开发(高级),HarmonyOS 应用开发者高级认证,现在某学校任教。 136

【数据集5】土地利用类型数量预测数据LUH2

简介土地利用类型数量预测数据LUH2

WW、forever的博客 4547

UVA12478 Hardest Problem Ever (Easy)【水题】

IUT once asked a group of people to prepare a number of problems for their yearly national contest. That group of people (let’s call them the setters) is really enthusiastic problem solvers, they grat...

海岛Blog 584

WIFI和BT测试(射频工程师)

买不了吃亏买不了上当,我卖的是技能,你收获的是经验。

m0_58834499的博客 599

HDU 1048 The Hardest Problem Ever

题目传送门: HDU 1048 The Hardest Problem Ever 题意:简单地按照规则翻译句子,比如输入A就得输出V. #include #include #include #include #include #include #include #include #include #include #include #define LL __int64 #define

WinForBest 426

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

The Hardest Problem Ever(字符串处理,易)

The Hardest Problem Ever Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10638    Accepted Submission(s): 4748 Problem Description

cs_zlg的专栏 4612

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

HDU——1048 The Hardest Problem Ever

Problem Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of t...

LightOn 706

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

HDU-1048-The Hardest Problem Ever(C++ && 偶尔一水......)

The Hardest Problem Ever Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 19343    Accepted Submission(s): 9061 Problem Description

保持对编程的热情! 1700
上一篇: ZJNU——1262电灯泡(三分题)
下一篇: D - Safecracker(模拟题)
ACMer_hades
博客等级 码龄12年 49粉丝 218原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值