Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- string str1, str2;
- cin >> str1 >> str2;
- int len1 = str1.length(),
- len2 = str2.length(),
- minLen = len1 >= len2 ? len2 : len1,
- maxLen = len1 >= len2 ? len1 : len2,
- result = 0;
- for (size_t i = 0; i < minLen; i++) {
- result += str1[i] * str2[i];
- }
- if (len1 != len2) {
- for (size_t i = minLen; i < maxLen; i++) {
- result += (len1 > len2 ? str1[i] : str2[i]);
- }
- }
- cout << result << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement