Max_Leb

F1

Feb 2nd, 2022
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int main()
  5. {
  6. FILE *inFile = fopen("input.txt", "r");
  7. FILE *outFile = fopen("output.txt", "w");
  8. char secret_word[15];
  9. for (int i = 0; i < 15; ++i)
  10. secret_word[i] = 0;
  11. fscanf(inFile, "%s", secret_word);
  12. int word_length = 0;
  13. for (int i = 0; i < 15; ++i)
  14. {
  15. if (secret_word[i] != 0)
  16. word_length++;
  17. }
  18.  
  19. char input_word[20];
  20. for (int i = 0; i < 20; ++i)
  21. input_word[i] = 0;
  22. fscanf(inFile, "%s", input_word);
  23.  
  24.  
  25. char result[15];
  26. for (int i = 0; i < 15; ++i)
  27. result[i] = '.';
  28.  
  29.  
  30. for (int i = 0; i < 20; ++i)
  31. {
  32. for (int j = 0; j < 15; ++j)
  33. {
  34. if (input_word[i] == secret_word[j] && input_word[i] != 0)
  35. {
  36. result[j] = result[j] == '.' ? secret_word[j] : '.';
  37. }
  38. }
  39. }
  40.  
  41. for (int i = 0; i < word_length; ++i)
  42. fprintf(outFile, "%c", result[i]);
  43.  
  44. fclose(inFile);
  45. fclose(outFile);
  46.  
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment