Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int solution(int A[12])
- {
- int wynik=0;
- int index=0;
- int licznik=0;
- int next_index=0;
- int i=0;
- for (i=0;i<12;i++){
- if(A[i]==NULL){
- continue;
- }
- cout << endl << "łancuszek: " << i << ">";
- index=i;
- licznik=1;
- do
- {
- licznik++;
- next_index=A[index];
- cout << next_index << ">";
- A[index]=NULL;
- index=next_index;
- }while(A[next_index]!=i && A[next_index]!=NULL);
- cout << i << " |";
- if(licznik>wynik){
- wynik=licznik;
- }
- }
- return wynik;
- }
- int main()
- {
- int tab[12] = {11, 2, 8, 5, 10, 6, 0,9,1,4,7,3};
- int b=0;
- b=solution(tab);
- cout<< endl << b;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement