利用容器类要简单许多 比起C语言
package test;
import java.util.ArrayList;
import java.util.List;
public class josef {
public static void main(String[] args) {
int count = 0;
List<Integer> ob = new ArrayList<Integer>();
for (int i = 1; i <= 100; i++) {
ob.add(i);
}
while (ob.size() > 0) {
for (int i = 0,j = ob.size();i<j; i++) {
++count;
if(count==3){
count=0;
ob.remove(i);
--i;
--j;
continue;
}
}
if(ob.size()==1){
System.out.println("Last Number:"+ob.get(0));
break;
}
}
}
}