delix777
Apr 22nd, 2023
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     string color1, color2, color3;
  7.     string color_Witness{"?"s};
  8.     int floors1, floors2, floors3;
  9.     int floors_Witness{-1};
  10.     // Считайте информацию о трёх домах, которые видит перед собой Марта,
  11.     cin >> color1 >> floors1 >> color2 >> floors2 >> color3 >> floors3;
  12.    
  13.     // а также показания очевидца.
  14.     cin >> color_Witness >> floors_Witness;
  15.    
  16.     // Выведите номера тех домов (1, 2, 3) которые нужно посетить,
  17.     // по одному номеру в каждой строке
  18.    
  19.     if( color_Witness != "?"s && floors_Witness != -1 ){ // ввел и цвет и этажность
  20.         if(color1 == color_Witness && floors1 == floors_Witness) {
  21.         cout << 1 << endl;
  22.         } if(color2 == color_Witness && floors2 == floors_Witness){
  23.             cout << 2 << endl;
  24.         } if(color3 == color_Witness && floors3 == floors_Witness){
  25.             cout << 3 << endl;
  26.         }
  27.        
  28.     } else if ( color_Witness == "?"s && floors_Witness == -1 ){ // не ввел ни цвет ни этажность
  29.         cout << 1 << endl;
  30.         cout << 2 << endl;
  31.         cout << 3 << endl;
  32.        
  33.     } if( color_Witness == "?"s || floors_Witness == -1 ){ // ввёл либо цвет либо этажность
  34.         if (color1 == color_Witness || floors1 == floors_Witness){
  35.             cout << 1 << endl;
  36.         } if (color2 == color_Witness || floors2 == floors_Witness){
  37.             cout << 2 << endl;
  38.         } if (color3 == color_Witness || floors3 == floors_Witness){
  39.             cout << 3 << endl;
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment