fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool my_operation (bool a, bool b, bool* res) {
  5. if (!a and !b) return res[0];
  6. else if (!a and b) return res[1];
  7. else if (a and !b) return res[2];
  8. else return res[3];
  9. }
  10.  
  11. int main() {
  12. int w, h;
  13. bool truth_t[4];
  14. cin >> w >> h;
  15. bool **first_t = new bool *[h];
  16. bool **second_t = new bool *[h];
  17. for (int i = 0; i < h; i++) {
  18. first_t[i] = new bool [w];
  19. second_t[i] = new bool [w];
  20. }
  21. char c;
  22. for (int i = 0; i < h; i++){
  23. for (int j = 0; j < w; j++) {
  24. cin >> c;
  25. first_t[i][j] = (c == '1' ? true : false);
  26. }
  27. }
  28. for (int i = 0; i < h; i++){
  29. for (int j = 0; j < w; j++) {
  30. cin >> c;
  31. second_t[i][j] = (c == '1' ? true : false);
  32. }
  33. }
  34. for (int i = 0; i < 4; i++) {
  35. cin >> c;
  36. truth_t[i] = (c == '1' ? true : false);
  37. }
  38. for (int i = 0; i < h; i++) {
  39. for (int j = 0; j < w; j++){
  40. cout << my_operation (first_t[i][j], second_t[i][j], truth_t);
  41. }
  42. if (i < h - 1) cout << endl;
  43. }
  44. return 0;
  45. }
Success #stdin #stdout 0s 15240KB
stdin
000
100
110
000
101
010
stdout