This is comment for paste
Логические операции «и», «или», «не»
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- string color1, color2, color3;
- string color_Witness{"?"s};
- int floors1, floors2, floors3;
- int floors_Witness{-1};
- // Считайте информацию о трёх домах, которые видит перед собой Марта,
- cin >> color1 >> floors1 >> color2 >> floors2 >> color3 >> floors3;
- // а также показания очевидца.
- cin >> color_Witness >> floors_Witness;
- // Выведите номера тех домов (1, 2, 3) которые нужно посетить,
- // по одному номеру в каждой строке
- if( color_Witness != "?"s && floors_Witness != -1 ){ // ввел и цвет и этажность
- if(color1 == color_Witness && floors1 == floors_Witness) {
- cout << 1 << endl;
- } if(color2 == color_Witness && floors2 == floors_Witness){
- cout << 2 << endl;
- } if(color3 == color_Witness && floors3 == floors_Witness){
- cout << 3 << endl;
- }
- } else if ( color_Witness == "?"s && floors_Witness == -1 ){ // не ввел ни цвет ни этажность
- cout << 1 << endl;
- cout << 2 << endl;
- cout << 3 << endl;
- } if( color_Witness == "?"s || floors_Witness == -1 ){ // ввёл либо цвет либо этажность
- if (color1 == color_Witness || floors1 == floors_Witness){
- cout << 1 << endl;
- } if (color2 == color_Witness || floors2 == floors_Witness){
- cout << 2 << endl;
- } if (color3 == color_Witness || floors3 == floors_Witness){
- cout << 3 << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment