Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- FILE *inFile = fopen("input.txt", "r");
- FILE *outFile = fopen("output.txt", "w");
- char secret_word[15];
- for (int i = 0; i < 15; ++i)
- secret_word[i] = 0;
- fscanf(inFile, "%s", secret_word);
- int word_length = 0;
- for (int i = 0; i < 15; ++i)
- {
- if (secret_word[i] != 0)
- word_length++;
- }
- char input_word[20];
- for (int i = 0; i < 20; ++i)
- input_word[i] = 0;
- fscanf(inFile, "%s", input_word);
- char result[15];
- for (int i = 0; i < 15; ++i)
- result[i] = '.';
- for (int i = 0; i < 20; ++i)
- {
- for (int j = 0; j < 15; ++j)
- {
- if (input_word[i] == secret_word[j] && input_word[i] != 0)
- {
- result[j] = result[j] == '.' ? secret_word[j] : '.';
- }
- }
- }
- for (int i = 0; i < word_length; ++i)
- fprintf(outFile, "%c", result[i]);
- fclose(inFile);
- fclose(outFile);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment