fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a[]={12,11,-13,-5,6,-7,5,-3,-6}
  6. int i,x,n=9;
  7. vector<int>arr;
  8. for(i=0;i<n;i++)
  9. {
  10. cin>>a[i];
  11. x=a[i];
  12. if(x>=0)
  13. arr.push_back(x);
  14. }
  15. for(i=0;i<n;i++)
  16. {
  17. x=a[i];
  18. if(x<0)
  19. arr.push_back(x);
  20. }
  21. for(i=0;i<n;i++)
  22. cout<<arr[i]<<" ";
  23. cout<<endl;
  24.  
  25. return 0;
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:6:13: error: expected ‘,’ or ‘;’ before ‘int’
             int i,x,n=9;
             ^~~
prog.cpp:8:17: error: ‘i’ was not declared in this scope
             for(i=0;i<n;i++)
                 ^
prog.cpp:8:23: error: ‘n’ was not declared in this scope
             for(i=0;i<n;i++)
                       ^
prog.cpp:11:13: error: ‘x’ was not declared in this scope
             x=a[i];
             ^
prog.cpp:15:13: error: ‘i’ was not declared in this scope
         for(i=0;i<n;i++)
             ^
prog.cpp:15:19: error: ‘n’ was not declared in this scope
         for(i=0;i<n;i++)
                   ^
prog.cpp:17:13: error: ‘x’ was not declared in this scope
             x=a[i];
             ^
prog.cpp:21:13: error: ‘i’ was not declared in this scope
         for(i=0;i<n;i++)
             ^
prog.cpp:21:19: error: ‘n’ was not declared in this scope
         for(i=0;i<n;i++)
                   ^
stdout
Standard output is empty