标签:
1 #include <stdio.h> 2 3 int main() 4 { 5 int N = 41; 6 int i = 1; 7 int m = 3; 8 int MAX = N; 9 int k, t; 10 int a[100], b[100]; 11 for (k = 0; k < N; k++) 12 { 13 b[k] = k + 1; 14 } 15 for(k = 0; k < MAX; k++) 16 { 17 t = (i + m - 1) % N; 18 if (t - 1 < 0) 19 { 20 a[k] = b[N-1]; 21 i = N; 22 } 23 else 24 { 25 a[k] = b[t-1]; 26 i = t; 27 while (t < N) 28 { 29 b[t-1] = b[t]; 30 t++; 31 } 32 } 33 N = N - 1; 34 printf("%i ", a[k]); 35 } 36 printf("\n"); 37 return 0; 38 }
标签:
原文地址:http://www.cnblogs.com/toorist/p/4845304.html