Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main() {
- ifstream fin("input.txt");
- ofstream fout("output.txt");
- char hidden[16];
- for (int i = 0; i < 15; ++i)
- hidden[i] = 0;
- fin >> hidden;
- int len = 0;
- for (int i = 0; i < 15; ++i) {
- if (hidden[i] != 0)
- ++len;
- }
- char guess[21];
- for (int i = 0; i < 20; ++i)
- guess[i] = 0;
- fin >> guess;
- char result[16];
- for (int i = 0; i < 15; ++i)
- result[i] = '.';
- for (int i = 0; i < 20; ++i) {
- for (int j = 0; j < 15; ++j) {
- if (guess[i] != 0 && guess[i] == hidden[j]) {
- result[j] = result[j] == '.' ? hidden[j] : '.';
- }
- }
- }
- for (int i = 0; i < len; ++i)
- fout << result[i];
- fin.close();
- fout.close();
- return 0;
- }
Add Comment
Please, Sign In to add comment