当前位置:网站首页>L1-059 敲笨钟 (20 分)
L1-059 敲笨钟 (20 分)
2022-04-21 22:15:00 【WTXYL】
微博上有个自称“大笨钟V”的家伙,每天敲钟催促码农们爱惜身体早点睡觉。为了增加敲钟的趣味性,还会糟改几句古诗词。其糟改的方法为:去网上搜寻压“ong”韵的古诗词,把句尾的三个字换成“敲笨钟”。例如唐代诗人李贺有名句曰:“寻章摘句老雕虫,晓月当帘挂玉弓”,其中“虫”(chong)和“弓”(gong)都压了“ong”韵。于是这句诗就被糟改为“寻章摘句老雕虫,晓月当帘敲笨钟”。
现在给你一大堆古诗词句,要求你写个程序自动将压“ong”韵的句子糟改成“敲笨钟”。
输入格式:
输入首先在第一行给出一个不超过 20 的正整数 N。随后 N 行,每行用汉语拼音给出一句古诗词,分上下两半句,用逗号 , 分隔,句号 . 结尾。相邻两字的拼音之间用一个空格分隔。题目保证每个字的拼音不超过 6 个字符,每行字符的总长度不超过 100,并且下半句诗至少有 3 个字。
输出格式:
对每一行诗句,判断其是否压“ong”韵。即上下两句末尾的字都是“ong”结尾。如果是压此韵的,就按题面方法糟改之后输出,输出格式同输入;否则输出 Skipped,即跳过此句。
输入样例:
5
xun zhang zhai ju lao diao chong, xiao yue dang lian gua yu gong.
tian sheng wo cai bi you yong, qian jin san jin huan fu lai.
xue zhui rou zhi leng wei rong, an xiao chen jing shu wei long.
zuo ye xing chen zuo ye feng, hua lou xi pan gui tang dong.
ren xian gui hua luo, ye jing chun shan kong.
输出样例:
xun zhang zhai ju lao diao chong, xiao yue dang lian qiao ben zhong.
Skipped
xue zhui rou zhi leng wei rong, an xiao chen jing qiao ben zhong.
Skipped
Skipped
代码:
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main(){
string str;
int n;
cin >> n;
getchar();
for(int i = 0; i < n; i ++){
getline(cin, str);
stringstream st(str);
bool flag1 = false, flag2 = false;
int len = 0;
while(st){
string s;
st >> s;
len ++;
if(s[s.size() - 1] == ',' && s.size() >= 4) {
if (s[s.size() - 4] == 'o' && s[s.size() - 3] == 'n' &&
s[s.size() - 2] == 'g')
flag1 = true;
}
else if(s[s.size() - 1] == '.' && s.size() >= 4) {
if (s[s.size() - 4] == 'o' && s[s.size() - 3] == 'n' &&
s[s.size() - 2] == 'g')
flag2 = true;
}
}
len -= 2;
if(flag1 && flag2){
stringstream sst(str);
string s;
sst >> s;
cout << s;
while(len > 3){
sst >> s;
cout << " " << s;
len --;
}
cout << " qiao ben zhong." << endl;
}
else
cout << "Skipped" << endl;
}
}
这题的输入输出太恶心了
版权声明
本文为[WTXYL]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_46891900/article/details/124220987
边栏推荐
猜你喜欢

Kotlin core programming, Android development, interview answer handler

外包学生管理系统架构设计文档

CPT 102_LEC 11

LeetCode146-LRU缓存-模拟-双向链表-哈希表-数据结构-操作系统

ROS——编译PCL相关程序报错:Could not find a package configuration file provided by “PCL“

Idea operates redis on Linux through jedis; Failed to connect to any host resolved for DNS name

每日一题-LeetCode824-山羊拉丁文-模拟

外包学生管理系统详细架构设计文档
![[webgl] simple tutorial](/img/11/208371dbc9bb1175f199ed21d4f651.png)
[webgl] simple tutorial

OpenCV中的Core组件——输入输出XML, YAML(12)
随机推荐
CC10000. MySQL———————————————
HTTP cache notes
每日一题-LeetCode824-山羊拉丁文-模拟
Oracle cascade delete table (not subject to foreign key constraints)
STM32外设GPIO的配置和应用
CC10000. ZABBIX———————————————
CC10000.MySQL———————————————
【ES6】Generator
Unity3d import tilt model, etc
软件设计师——第六章:系统安全分析与设计
Fundamentals of Power Electronics
GD32F103学习笔记(8)——ADC接口使用
CPT 102_ LEC 11
Record a pit in the split3 Library (table name and field definition cannot use placeholders?)
【ES6】Iterator和forof循环
【ES6】Generator
Start debugging the dynamic linker of C Library-2 -- musl-c
Finding a way to combine new technologies with itself is the key to the development of industrial Internet
CC00012.ZABBIX———————————————
2022年中级会计职称考试会计实务练习题及答案