|
|
вернуться в форумОбщий форумWrong Answer. What's wrong in my program? I'm sure that i'm right! №1024 #include <cstdio> using namespace std; /* * */ int main() {
unsigned int k = 0; unsigned int i; unsigned int n; scanf("%u",&n); unsigned int mas1[1000],mas2[1000]; for(i = 1;i<=n;i+=1) { scanf("%u",&mas1[i]); mas2[i] = mas1[i]; } unsigned int a = 0; unsigned int s = 0; unsigned int m = 0; do { for(int j = 1;j<=n;j+=1) { if (j == mas2[j]){ k+=1;} } for(i = 1;i<=n;i+=1) { s = mas2[i]; mas2[i] = mas1[s]; } if ( k == n) { m=1;} else {k = 0;} a+=1; } while (m!=1); printf("%u\n",a); return 0; } |
|
|