Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- int f(std:: vector<int> v)
- {
- bool ponavlja=false;
- int brojac=0;
- for(int l=1;l<v.size();l++)
- {
- if(v[0]==v[l])
- {
- ponavlja=true;
- brojac++;
- break;
- }
- else brojac++;
- }
- bool ne=false;
- if(ponavlja)
- {
- for(int i=0;i<v.size();i++)
- {
- for(int j=i;j<v.size();j+=brojac)
- {
- if(v[i]!=v[j])
- {
- ne=true;
- break;
- }
- }
- }
- }
- else brojac=0;
- if(ne) brojac=0;
- return brojac;
- }
- int main()
- {
- std::vector <int> brojevi;
- int n;
- std::cout << "Unesite brojeve:" << std::endl;
- for(;;)
- {
- std::cin>>n;
- if(n==0) break;
- else
- brojevi.push_back(n);
- }
- std::cout<<"Period je: "<<f(brojevi)<<std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement