Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- using namespace std;
- void funkcija(vector<int> &v){
- vector<int> pom ;
- pom.push_back(v[0]);
- bool uslov(true);
- for( int i=1 ; i < v.size() ; i++ ) {
- if( v[i] == v[0] ) break ;
- pom.push_back(v[i]);
- }
- for ( int i = 0 ; i < v.size() ; i++ ) {
- for ( int j = 0 ; j < pom.size() ; j++ ) {
- if ( v[i+j] != pom [j] ) uslov = false ;
- }
- if (uslov) i+=pom.size()-1;
- else if ( !uslov ) break ;
- }
- cout << endl ;
- if ( uslov ) cout<< "Funkcija ima period " << pom.size();
- else if ( !uslov ) cout << "Funkcija nije periodicna" ;
- }
- int main()
- {
- vector<int> v;
- int a;
- for ( int i = 0 ; i < 4 ; i++ ) {
- for ( int j = 1 ; j < 5 ; j++ ) {
- v.push_back(j);
- }
- }
- funkcija(v);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement