A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© lingxia125 中级黑马   /  2015-7-28 11:36  /  314 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 lingxia125 于 2015-9-11 17:44 编辑
  1. </blockquote><blockquote><div class="blockcode"><blockquote>class LuckNumber
  2. {
  3.         public static void main(String[] args)
  4.         {
  5.                 int[] arr = {1,2,3,4,5,6,7,8};

  6.                 int pos = -1;

  7.                 for(int x=0;x<arr.length-1; x++)
  8.                 {
  9.                         for(int y=0; y<3;y++)
  10.                         {
  11.                                 pos++;

  12.                                 if(pos==arr.length)
  13.                                         pos=0;
  14.                                 while(arr[pos]==0)
  15.                                 {
  16.                                         pos++;
  17.                                         if(pos==arr.length)
  18.                                                 pos=0;
  19.                                 }
  20.                         }
  21.                         arr[pos] = 0;
  22.                         //System.out.println(arr[pos]);
  23.                 }

  24.                 for(int x=0; x<arr.length; x++)
  25.                 {
  26.                         if(arr[x]!=0)
  27.                         {
  28.                                 System.out.println(arr[x]);
  29.                                 break;
  30.                         }
  31.                 }
  32.         }
  33. }
复制代码

帮我解释一下这个代码,看不懂!谢谢啦!

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马