fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main(void) {
  6. int be[] = { 1001, 1001, 1001, 101, 1001 };
  7. int beSize = (sizeof(be)/sizeof(*be));
  8. bool fl = false;
  9. int i=0;
  10. for (i;i<beSize;i++)
  11. {
  12. if (be[i]>=1000)
  13. {
  14. if (!fl) {
  15. fl=true;
  16. cout<<i+1<<" ";
  17. }
  18. } else {
  19. if (fl) {
  20. fl=false;
  21. cout<<i<<" ";
  22. }
  23. }
  24. }
  25. if (fl) { cout<<i<<" "; }
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
1 3 5 5