美文网首页
基础练习 01字串

基础练习 01字串

作者: ZaleJ | 来源:发表于2018-03-03 10:17 被阅读0次
    image.png
    public class Main {
        public static void main(String[] args){
            bool boo = new bool();
            boo.show();
            for(int i = 0; i < 31; i++){
                boo.OP();
                boo.show();
            }
    
    
        }
    }
    
    class bool{
        int[] b = new int[5];
        public bool(){
            for(int i = 0; i < b.length; i++){
                b[i]=0;
            }
        }
    
        public void OP(){
            for (int i = b.length-1; i > -1; i--){
                if(b[i]==0){
                    b[i]=1;
                    return;
                }else{
                    b[i]=0;
                }
            }
        }
    
        public void show(){
            for(int x : b){
                System.out.print(x);
            }
            System.out.println();
        }
    }
    

    相关文章

      网友评论

          本文标题:基础练习 01字串

          本文链接:https://www.haomeiwen.com/subject/adltfftx.html