Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int check_item (int array[], int i )
- {
- if (array[i] == -1)
- return 0;
- else
- return 1;
- }
- int main()
- {
- int n = 6;
- int f = 0;
- int cont = 0;
- int array[6] = {1,2,0,5,3,4};
- int i = 0;
- int aux_i = 0;
- int flag = 0;
- while (cont < n)
- {
- printf("i = %d\n",i);
- if (check_item(array, i) == 0)
- {
- f =+1;
- aux_i += 1;
- flag = 1;
- }
- else
- {
- if (flag == 0)
- aux_i = i;
- else
- i = aux_i;
- array[i] = -1;
- i = aux_i;
- flag = 0;
- cont +=1;
- i = array[aux_i];
- }
- }
- printf("Familias = %d\n",f);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement