Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <array>
- #include <cctype>
- const int maxSize = 150;
- std::array<char, maxSize> readInput(int& textSize) {
- std::array<char, maxSize> arr{};
- for (int i = 0; i < textSize; ++i) {
- std::cin >> arr[i];
- }
- return arr;
- }
- void Solution(std::array<char, maxSize>& textOne, std::array<char, maxSize>& textTwo, int& textSize) {
- int differences = 0;
- for (int i = 0; i < textSize; ++i) {
- if (textOne[i] == textTwo[i]) {
- std::cout << textOne[i];
- }
- else if (std::abs(textOne[i] - textTwo[i]) == 32 && !ispunct(textOne[i]) && !ispunct(textTwo[i])) {
- if (isalpha(textOne[i])) {
- std::cout << textTwo[i];
- }
- else if (isalpha(textTwo[i])) {
- std::cout << textOne[i];
- }
- }
- else if (textOne[i] != textTwo[i]) {
- std::cout << '!';
- differences++;
- }
- }
- std::cout << std::endl;
- std::cout << differences;
- }
- int main() {
- int textSize;
- std::cin >> textSize;
- std::array<char, maxSize> textOne = readInput(textSize);
- std::array<char, maxSize> textTwo = readInput(textSize);
- Solution(textOne, textTwo, textSize);
- }
Advertisement
Add Comment
Please, Sign In to add comment