当前位置:网站首页>L1-059 ring stupid bell
L1-059 ring stupid bell
2022-07-24 11:42:00 【Cod_ ing】
A problem that is not very difficult , But pay attention to the pit !
#include<iostream>
#include<string>
using namespace std;
int main() {
string s;
int N;
cin >> N;
getchar();
for (int i = 0; i < N; i++) {
getline(cin, s);
int pos=s.find(",");
string ong1,ong2;
if (pos < 3) {
// Pay attention to the length of the first half
cout << "Skipped";
if (i != N - 1) cout << endl;
continue;
}
ong1 = s.substr(pos - 3, 3);
ong2 = s.substr(s.size() - 4, 3);
if (ong1 != "ong" || ong2 != "ong") cout << "Skipped";
else {
for (int j = 0; j < 3; j++) {
int pos1 = s.rfind(" "); // Delete from back to front 3 A word , A space represents a word
s.erase(pos1);
}
s += " qiao ben zhong.";
cout << s;
}
if (i != N - 1) cout << endl;
}
return 0;
}
Description of the input format of the topic :
The input first gives a no more than 20 The positive integer N. And then N That's ok , Each line of ancient poetry is given in pinyin , Divide the sentence into two parts , Comma , Separate , Full stop . ending . A space is used to separate the Pinyin of two adjacent characters . The title ensures that the Pinyin of each word does not exceed 6 Characters , The total length of each line of characters does not exceed 100, also The second half of the poem has at least 3 A word .
That is to say, the first half of the sentence may have no words , So you need this code
if (pos < 3) {
cout << "Skipped";
if (i != N - 1) cout << endl;
continue;
}
Otherwise, a test point will be lost 
After special judgment 
When it comes to length , Pay attention to whether the subscript of the target object will exceed the limit !
边栏推荐
- JMeter runtime controller
- Sorting out the ideas of data processing received by TCP server, and the note of select: invalid argument error
- [QNX Hypervisor 2.2用户手册]9.2 cmdline
- 源码分析Sentry用户行为记录实现过程
- cgo+gSoap+onvif学习总结:9、go和c进行socket通信进行onvif协议处理
- [golang] golang implements the string interception function substr
- tcp 服务端接收数据处理思路梳理,以及select: Invalid argument报错 笔记
- IT圈中的Bug的类型与历史
- 使用Prometheus+Grafana实时监控服务器性能
- How to access the code of online customer service system to your website
猜你喜欢

Cgo+gsoap+onvif learning summary: 9. Go and C conduct socket communication and onvif protocol processing

字符串——344.反转字符串

Jmeter-While控制器

PDF处理还收费?不可能!

The art of management - driving software R & D efficiency through leadership
![Operational amplifier - Notes on rapid recovery [II] (application)](/img/fd/e12f43e23e6ec76c2b44ce7813e204.png)
Operational amplifier - Notes on rapid recovery [II] (application)

HCIP MGRE实验 第三天

【反序列化漏洞-02】PHP反序列化漏洞原理测试及魔术方法总结

What is the charm of CSDN members? What's the use of him?

Types and history of bugs in it circle
随机推荐
6k+ star,面向小白的深度学习代码库!一行代码实现所有Attention机制!
In BS4.String and Difference between text
Shell script
How to go from functional testing to automated testing?
HCIP MGRE实验 第三天
运算放大器 —— 快速复苏笔记[壹](参数篇)
【反序列化漏洞-01】序列化与反序列化简介
第0章 前言和环境配置
字符串——541. 反转字符串 II
How to access the code of online customer service system to your website
Leetcode 112. 路径总和
Linked list - 142. Ring linked list II
L1-043 阅览室
Code of login page
IT圈中的Bug的类型与历史
scrapy-redis写项目备忘
Stack Title: basic calculator II
Record a garbage collection and analysis of gceasy
Talk about software testing - automated testing framework
Detailed explanation of stat function