Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- bool PrebrojParneNeparne(vector<int> a, int &pozitivni, int &negativni)
- {
- int br1(0), br2(0);
- for(int i=0; i<a.size(); i++)
- {
- if(a[i] > 0)
- br1++;
- else if(a[i] < 0) br2++;
- }
- pozitivni = br1;
- negativni = br2;
- for(int i=0; i<a.size(); i++)
- {
- if(a[i]==0) return true;
- else if(a[i]!=0) if(i==a.size()-1) return false;
- }
- }
- int main()
- {
- vector<int> v;
- int pozitivni, negativni;
- int n; int broj;
- cout<<"Unesite broj elemenata vektora: ";
- cin>>n;
- cout<<"Unesite elemente vektora: ";
- for(int i=0; i<n; i++)
- {
- cin>>broj; v.push_back(broj);
- }
- if(PrebrojParneNeparne(v, pozitivni, negativni))
- cout<<"Postoji neki broj koji je jednak nuli.\n";
- else
- cout<<"Nema brojeva koji su jednaki nuli.\n";
- cout<<pozitivni<<" "<<negativni;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement