Advertisement
STANAANDREY

2vect

Mar 27th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream f("BAC.txt");
  5. int main()
  6. {
  7.  
  8. int n,i,n1=0,n2=0;
  9. float a[1000],b[1000],v[1000];
  10. cout<<"n=";cin>>n;
  11. for (i=0;i<n;i++)
  12. cin>>v[i];
  13.  
  14. for (i=0;i<n;i++)
  15. {
  16.     if (v[i]>0)
  17.     {
  18.         a[n1]=v[i];
  19.         n1++;
  20.     }
  21.     else if (v[i]<0)
  22.     {
  23.         b[n2]=v[i];
  24.         n2++;
  25.     }
  26. }
  27. cout<<"sir poz:"<<endl;
  28. for (i=0;i<n1;i++)
  29. cout<<a[i]<<' ';
  30. cout<<endl;
  31. cout<<"sir neg:"<<endl;
  32. for (i=0;i<n2;i++)
  33.     cout<<b[i]<<' ';
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement