L1-059 敲笨钟
题目 L1-059 敲笨钟
思路分析
代码实现
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
using ll = long long;
using ull = unsigned long long;
using PII = pair<int,int>;
using Pll = pair<ll,ll>;
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int inf = 0x3f3f3f3f;
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int n;cin>>n;
cin.ignore();
while(n--){
string s;getline(cin,s);
int sb=s.find(',');
int shangbanyun=sb-3;
string sby;
for(int j=shangbanyun;j<sb;j++){
sby+=s[j];
}
// cout<<sby<<" ";
int xb=s.find('.');
int xiabanyun=xb-3;
string xby;
for(int j=xiabanyun;j<xb;j++){
xby+=s[j];
}
// cout<<xby<<endl;
string ans;
if(sby=="ong" && xby=="ong"){
int cnt=0;
int pos=s.size()-1;
while(cnt<3 && pos>=0){
if(s[pos]==' ') cnt++;
pos--;
}
ans=s.substr(0,pos+1)+" qiao ben zhong.";
cout<<ans<<endl;
}
else cout<<"Skipped"<<endl;
}
return 0;
}
同类题型
视频讲解
⬅️ L1-058 6翻了 🏠 00-天梯赛 ➡️ L1-060 心理阴影面积
💬 评论