Max_Leb

F1

Feb 2nd, 2022 (edited)
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ifstream fin("input.txt");
  8. ofstream fout("output.txt");
  9.  
  10. char hidden[16];
  11. for (int i = 0; i < 15; ++i)
  12. hidden[i] = 0;
  13. fin >> hidden;
  14.  
  15. int len = 0;
  16. for (int i = 0; i < 15; ++i) {
  17. if (hidden[i] != 0)
  18. ++len;
  19. }
  20.  
  21.  
  22. char guess[21];
  23. for (int i = 0; i < 20; ++i)
  24. guess[i] = 0;
  25. fin >> guess;
  26.  
  27. char result[16];
  28. for (int i = 0; i < 15; ++i)
  29. result[i] = '.';
  30.  
  31. for (int i = 0; i < 20; ++i) {
  32. for (int j = 0; j < 15; ++j) {
  33. if (guess[i] != 0 && guess[i] == hidden[j]) {
  34. result[j] = result[j] == '.' ? hidden[j] : '.';
  35. }
  36. }
  37. }
  38.  
  39.  
  40. for (int i = 0; i < len; ++i)
  41. fout << result[i];
  42.  
  43. fin.close();
  44. fout.close();
  45.  
  46. return 0;
  47. }
Add Comment
Please, Sign In to add comment