package test;
/**
*
* 有编号从1到N的N个人坐成一圈报数,报到M的人出局,下一位再
* 从1开始,如此持续,直止剩下一位为止,报告此人的编号X。输入N,M,求出X。
*/
public class test {
public static void main(String args[]) {
int n = 10, m = 3, FLAG = m, j = 0, sum = 0;
int count = n - 1;
int total = 55;
int store[] = new int[n - 1];
int i = 0;
while ((count--) != 0) {
store[j] = FLAG;
j++;
while (i != m) {
FLAG++;
if (FLAG > n) {
FLAG -= n;
}
if (judge(store, FLAG)) {
i++;
}
}
i = 0;
}
for (int k = 0; k < store.length; k++) {
System.out.print(store[k] + "/t");
sum += store[k];
}
System.out.println("");
System.out.println(total - sum);
}
public static boolean judge(int a[], int num) {
for (int i = 0; i < a.length; i++) {
if (num == a[i]) {
return false;
}
}
return true;
}
}