Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- int main()
- {
- using namespace std;
- size_t len;
- cin >> len;
- string str1, str2;
- cin >> str1 >> str2;
- size_t num_diff = 0, sum_digits = 0;
- for (size_t i = 0; i < len; ++i)
- {
- if (str1[i] == str2[i])
- cout << str1[i];
- else if (isalpha(str1[i]) && isalpha(str2[i]) && abs(str1[i] - str2[i]) == 32)
- cout << __min(str1[i], str2[i]);
- //else if (toupper(str1[i]) == toupper(str2[i]))
- // cout << (char)toupper(str1[i]);
- else
- {
- cout << '#';
- ++num_diff;
- }
- if (isdigit(str1[i]))
- sum_digits += str1[i] - '0';
- if (isdigit(str2[i]))
- sum_digits += str2[i] - '0';
- }
- cout << endl << num_diff << endl << len - num_diff << endl << sum_digits << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment