Advertisement
askarulytarlan

Задача №67. Есть ли два элемента с одинаковыми знаками

Oct 25th, 2016
1,112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cmath>
  4. #include <math.h>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. int massive[100];
  10. int d;
  11. int positive = 0;
  12. int main(int argc, const char * argv[]) {
  13. cin >> d;
  14. for(int i = 1; i <= d; i++){
  15. cin >> massive[i];
  16. }
  17. for(int i = 1; i < d; i++){
  18. if(massive[i] >= 0 && massive[i+1] >= 0){
  19. positive = positive + 1;
  20. }
  21. if(massive[i] <= 0 && massive[i+1] <= 0){
  22. positive = positive + 1;
  23. }
  24. }
  25. if(positive > 0){
  26. cout << "YES";
  27. }
  28. else {
  29. cout << "NO";
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement