L1-086 斯德哥尔摩火车上的题
题目 L1-086 斯德哥尔摩火车上的题
思路分析
代码实现
#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);
string s1,s2,a1,a2;
cin>>a1>>a2;
for (int i = 1; i < a1.size(); i++) {
if (a1[i] % 2 == a1[i-1] % 2) {
s1 += max(a1[i], a1[i-1]);
}
}
cout<<s1<<endl;
for (int i = 1; i < a2.size(); i++) {
if (a2[i] % 2 == a2[i-1] % 2) {
s2 += max(a2[i], a2[i-1]);
}
}
if(s2!=s1)
cout<<s2<<endl;
return 0;
}
同类题型
视频讲解
⬅️ L1-085 试试手气 🏠 00-天梯赛 ➡️ L1-087 机工士姆斯塔迪奥
💬 评论