Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- string s, t;
- cin >> s >> t;
- int cnt = 0;
- for(int i = 0; i < s.length(); i++)
- {
- if(i + 1 != s.length())
- {
- if(s[i] != t[i] && s[i+1] != t[i+1])
- {
- if(s[i] == t[i+1] && s[i+1] == t[i]) cnt++;
- else
- {
- printf("No\n");
- return 0;
- }
- }
- }
- }
- bool somannai = false;
- for(int i = 0; i < s.length(); i++)
- {
- if(s[i] != t[i])
- {
- somannai = true;
- break;
- }
- }
- if(!somannai) printf("Yes\n");
- else if(cnt == 1) printf("Yes\n");
- else printf("No\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment