PAT L1-059. 敲笨钟
原题链接
简单
作者:
青丝蛊
,
2021-04-09 15:44:59
,
所有人可见
,
阅读 305
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
while (n--)
{
cin.get(); // 吃一下回车
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;
}