Предмет: Информатика, автор: may10miackishev

Вводится последовательность чисел, 0-конец последовательности. Определить, содержит ли последовательность хотя бы два равных соседних числа.c++ while​

Ответы

Автор ответа: iknowthatyoufeelbro
0

Ответ:

#include <iostream>

using namespace std;

int main() {

int prev = 0;

bool hasTwoEquals = false;

while(true){

 int cur;

 cin >> cur;

 if (cur == 0){

  break;

 }

 if (prev == cur){

  hasTwoEquals = true;

  break;

 }

 prev = cur;

}

if (hasTwoEquals){

 cout << "Yes" << endl;

}

else{

 cout << "No" << endl;

}

return 0;

}

Похожие вопросы
Предмет: Английский язык, автор: cat16450
ПОМОГИЕ СРОЧНО
ДАМ БАЛОВ
1.John said that he … this place before.
a) has never seen b) never saw c) had never seen

2.At the moment John … a newspaper.
a) reads b) is reading c) read

3.My mother was cooking dinner while I … TV.
a) was watching b) watching c) have watched

4.I came home after I … my work.
a) had finished b) finished c) was finishing

5.They sent all the letters they … before.
a) wrote b) written c) had written

6. This book is interesting, but “Harry Potter” is … .
a) more interesting b) interestinger c) interesting

7. ____ Robinsons went to ____ Black Sea.
a) the, the b) -,- c) a, the

8. You are … a great friend.
a) so b) such

9. Your sister goes to the gym every day, ?
a) does she b) doesn’t she c) goes she

10. You haven’t been to the doctor’s yet, ?
a) have you b) haven’t you с)did you

11. Giles and Miles can’t drive, ?
a) can they b) do they c) can’t they

12 Henry usually walks the dog ______.
a) herself b) himself c) yourself

13. They introduced _____.
a) myself b)itself c) themselves

14. To cook supper you need a __________ .
a)telephone b) cooker c) broom

15. London is famous … its historical places.
a) about b) for c) in
16. If you`re overweight you should keep to … .

a)a fat diet
b) a vegetarian diet
c) a chocolate diet

17. The healthy lifestyle means to … .

a) avoid bad habits b) avoid keeping fit c) do what you wish

18.We stopped for _____________to eat.
a) anything b) something

19. How _________ water do you drink?
a) much b) many

20. My brother and I … our flat next Sunday.
a) cleaned b) will clean c) were cleaning