java 数三退一

来源:互联网 发布:软件企业证书 编辑:程序博客网 时间:2024/06/09 21:05
public class Count3Qiut {public static void main(String args[]){boolean[] boo = new boolean[500];for(int i=0;i<boo.length;i++){boo[i] = true;}int count = 0;int index = 0;int booLength = 500;  //表示true的个数while(booLength > 1){if(boo[index] == true){count++;if(count == 3){count = 0;boo[index] = false;booLength--;}}index++;if(index == boo.length){index  = 0;}}for(int i =0;i<boo.length;i++){if(boo[i]){System.out.println(i);}}}}


0 0
原创粉丝点击