Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3.  
  4. using namespace std;
  5.  
  6. void funkcija(vector<int> &v){
  7. vector<int> pom ;
  8. pom.push_back(v[0]);
  9. bool uslov(true);
  10. for( int i=1 ; i < v.size() ; i++ ) {
  11. if( v[i] == v[0] ) break ;
  12. pom.push_back(v[i]);
  13. }
  14. for ( int i = 0 ; i < v.size() ; i++ ) {
  15. for ( int j = 0 ; j < pom.size() ; j++ ) {
  16. if ( v[i+j] != pom [j] ) uslov = false ;
  17. }
  18. if (uslov) i+=pom.size()-1;
  19. else if ( !uslov ) break ;
  20. }
  21. cout << endl ;
  22. if ( uslov ) cout<< "Funkcija ima period " << pom.size();
  23. else if ( !uslov ) cout << "Funkcija nije periodicna" ;
  24. }
  25.  
  26. int main()
  27. {
  28. vector<int> v;
  29. int a;
  30. for ( int i = 0 ; i < 4 ; i++ ) {
  31. for ( int j = 1 ; j < 5 ; j++ ) {
  32. v.push_back(j);
  33. }
  34. }
  35. funkcija(v);
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement