Decompose a permutation into cycles
C 145 134 Characters

N,A[999],i,j,f;main(){gets(&amp;i);for(;~scanf("%d",A+N);)N++;for(;j&lt;N;j++,f=f&amp;&amp;!puts(""))while(i=A[j]+1)f=printf("%d ",j),A[j]=-1,j=--i;}


http://www.ideone.com/BrWJT