Advertisement
a53

meteo

a53
Feb 27th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. // Prof.Anca Uriciuc
  2. #include <fstream>
  3. using namespace std;
  4. ifstream fin("meteo.in");
  5. ofstream fout("meteo.out");
  6. int nrmax, k, i, t, a[1001], n;
  7. int main()
  8. {
  9. fin >> n;
  10. nrmax = 0;
  11. k = 1;
  12. for (i = 1; i <= n; i++)
  13. fin >> a[i];
  14. for (i = 2; i <= n; i++) {
  15. if ((a[i] >= 0 && a[i-1] < 0) || (a[i-1] >= 0 && a[i] < 0))
  16. k++;
  17. else {
  18. if (k >= nrmax) {
  19. nrmax = k;
  20. t = i-1;
  21. }
  22. k = 1;
  23. }
  24. }
  25. if (k >= nrmax) {
  26. nrmax = k;
  27. t = i-1;
  28. }
  29. if ( nrmax == 1)
  30. fout << 0 << '\n';
  31. else {
  32. fout << nrmax << '\n';
  33. for (i = t+1-nrmax; i <= t; i++)
  34. fout << a[i] <<" ";
  35. fout << '\n';
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement