当前位置:网站首页>Knock stupid l1-059
Knock stupid l1-059
2022-04-22 00:16:00 【EnochChen_】
PTA | Program design experiment auxiliary teaching platform
At first I didn't understand , How to split a sentence into , And judge
The following is the first input in the judgment , If before the comma ong also . So is the front ong That's the rhyme
And judge the first few words according to the blank space
#include <iostream>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
string s;
int main() {
int n;
cin >> n;
getchar();
while (n--) {
getline(cin, s);
int f1 = 0, f2 = 0, num = 0;
for (int i = 0; i < s.size(); ++i) {
if (s[i] == ',')
if (s[i - 3] == 'o' && s[i - 2] == 'n' && s[i - 1] == 'g')
f1 = 1;
if (s[i] == '.')
if (s[i - 3] == 'o' && s[i - 2] == 'n' && s[i - 1] == 'g')
f2 = 1;
if (s[i] == ' ')
num++;
}
if (f1 && f2) {
for (int i = 0; i < s.size(); ++i) {
if (num == 2)
break;
cout << s[i];
if (s[i] == ' ')
num--;
}
cout << "qiao ben zhong.";
} else {
cout << "Skipped";
}
cout << "\n";
}
return 0;
}
The following judgment is a little different , He is divided into two inputs , hold getline Play understand belong to
Then judge in reverse order where to output
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
while (n--) {
cin.get(); // and getchar The effect is the same
string s1, s2;
getline(cin, s1, ',');
getline(cin, s2, '.');
int l1 = s1.size(), l2 = s2.size();
if (s1[l1 - 1] != 'g' || s1[l1 - 2] != 'n' || s1[l1 - 3] != 'o' || s2[l2 - 1] != 'g' || s2[l2 - 2] != 'n'
|| s2[l2 - 3] != 'o')
puts("Skipped");
else {
cout << s1 << ',';
int i, cnt = 0;
for (i = s2.size(); i >= 0; i--) {
if (s2[i] == ' ')
cnt++;
if (cnt == 3)
break;
}
for (int j = 0; j <= i; j++)
cout << s2[j];
cout << "qiao ben zhong.\n";
}
}
return 0;
}
版权声明
本文为[EnochChen_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220011569441.html
边栏推荐
- 【无标题】2022煤炭生产经营单位(机电运输安全管理人员)上岗证题目模拟考试平台操作
- excel下拉框引用另外一个sheet
- Activity preview | on April 23, a number of wonderful openmldb sharing came, which lived up to the good time of the weekend!
- Blender MMD export FBX models and bake animations
- 2022年起重机械电气安装维修考试题库模拟考试平台操作
- MES实施过程中为什么会出现需求变更?又该如何解决?
- seo关键词扩展-自动关键词拓展软件免费下载
- dp 优化
- Gorm operation MySQL
- 深度学习(15):kitti数据集转rosbag包工具kitti2bag使用说明
猜你喜欢

TVS二极管的应用与分析

Detailed explanation of TCP's three handshakes

Sp4522b is a mobile power IC with integrated output for 2A charging and boosting

Oil monkey script synchronization

LeetCode_62 不同路径

深度学习(15):kitti数据集转rosbag包工具kitti2bag使用说明

Application layer (I)

The shadow ticket rebate system developed by uniapp + PHP can operate perfectly

Extreme value theory of R language: visualization of tail index parameter estimation of hill statistics

excel下拉框引用另外一个sheet
随机推荐
Extreme value theory of R language: visualization of tail index parameter estimation of hill statistics
2022质量员-装饰方向-岗位技能(质量员)考试模拟100题模拟考试平台操作
R language generalized linear model GLM: linear least squares, logarithmic transformation, Poisson, binomial logistic regression analysis, ice cream sales time series data and simulation
应用层(一)
Why should relays be connected in parallel with diodes
2022年江西省安全员A证考试题及答案
Unity determines whether the file (under the local absolute directory) exists
CocosCreator学习示例合集v3.4.2
redis源码之链表(adlist.h和adlist.c)(篇一)
CODESYS读取csv文件的方法(非excel)
小程序 分包
展平多级双向链表-c语言
数据可视化软件有什么特点
University four years, self-study programming commonly used 10 learning websites
CoDeSys method of reading CSV file (non Excel)
busybox概述
Detailed explanation of slam monocular dense reconstruction
Brush questions (I)
gorm 操作mysql
slam 单目稠密重建详解