找回密码
 快速注册

QQ登录

只需一步,快速开始

查看: 4579|回复: 8

几道逻辑性强的java基础题

[复制链接]
solimh 发表于 2011-9-3 15:17:58 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?快速注册

×
几道逻辑性强的java基础题

java私塾教程视频中找了几个,感觉很有意思,分享一下

1、两个乒乓球队进行比赛,各出三人。甲队为a,b,c 三人,乙队为x,y,z 三人。已抽签决定比赛名单。有人向队员打听比赛的名单。a 说他不和x 比,c 说他不和x,z 比,请编程序找出三队赛手的名单。

2、某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密规则如下:每位数字都加上5,然后用和除以10 的余数代替该数字,再将第一位和第四位交换,第二位和第三位交换。请编写一个方法来实现上述加密算法。

3、企业发放的奖金根据利润提成。利润低于或等于10 万元时,奖金可提10%;利润高于10 万元,低于20 万元时,低于10 万元的部分按10%提成,高于10 万元的部分,可提成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40 万到60 万之间时高于40万元的部分,可提成3%;60 万到100 万之间时,高于60 万元的部分,可提成1.5%,高于100 万元时,超过100 万元的部分按1%提成,请编写程序,输入当月利润,求应发放奖金总数?

4、 老伯伯要带鱼、狗、猫过河到对岸.,有一条船,只能坐一个人,老伯每次只能带一样动物过河,当老伯不在的时侯狗会咬猫,猫会吃鱼.,请问怎么顺序过河呢?要求:编写程序,由程序来推出过河的顺序

5、参加会议:有人邀请A,B,C,D,E,F6个人参加一项会议,这6个人有些奇怪,因为他们有很多要求,已知:
(1).A,B两人至少有1人参加会议。
(2).A,E,F3人中有2人参加会议。
(3).B和C两人一致决定,要么两人都去,要么两人都不去。
(4).A,D两人中只1人参加会议。
(5).C,D两人中也只要1人参加会议。
(6).如果D不去,那么E也决定不去。
那么最后究竟有哪几个人参加了会议呢?

6、有一位厨师要从盛12斤油(a桶)的桶中倒出6斤油来,可是手边只有盛8斤油(b桶)和盛5斤油(c桶)的两个桶,问如何操作才能将6斤取出来呢?

7、有一根27厘米的细木杆,在第3厘米、7厘米、11厘米、17厘米、23厘米这五个位置上各有一只蚂蚁。木杆很细,不能同时通过一只蚂蚁。开始时,蚂蚁的头朝左还是朝右是任意的,它们只会朝前走或调头,但不会后退。当任意两只蚂蚁碰头时,两只蚂蚁会同时调头朝反方向走。假设蚂蚁们每秒钟可以走一厘米的距离。编写程序,求所有蚂蚁都离开木杆的最小时间和最大时间。

8、一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在 第10次落地时,共经过多少米?第10次反弹多高?

9、程序分析:对n进行分解质因数,应先找到一个最小的质数k,然后按下述步骤完成:
(1)如果这个质数恰等于n,则说明分解质因数的过程已经结束,打印出即可。
(2)如果n<>k,但n能被k整除,则应打印出k的值,并用n除以k的商,作为新的正整数n,重复执行第一步。
(3)如果n不能被k整除,则用k+1作为k的值,重复执行第一步。

10、用程序求解:
请回答下面10个问题:
1、第一个答案是b的问题是哪一个?
(a)2;(b) 3;(c)4;(d)5;(e)6
2、唯一的连续两个具有相同答案的问题是:
(a)2,3;(b)3,4;(c)4,5;(d)5,6;(e)6,7;
3、本问题答案和哪一个问题的答案相同?
(a)1;(b)2;(c)4;(d)7;(e)6
4、答案是a的问题的个数是:
(a)0;(b)1;(c)2;(d)3;(e)4
5、本问题答案和哪一个问题的答案相同?
(a)10;(b)9;(c)8;(d)7;(e)6
6、答案是a的问题的个数和答案是什么的问题的个数相同?
(a)b;(b)c;(c)d;(d)e;(e)以上都不是
7、按照字母顺序,本问题的答案和下一个问题的答案相差几个字母?
(a)4;(b)3;(c)2;(d)1;(e)0。(注:a和b相差一个字母)
8、答案是元音字母的问题的个数是:
(a)2;(b)3;(c)4;(d)5;(e)6。(注:a和e是元音字母)
9、答案是辅音字母的问题的个数是:
(a)一个质数;(b)一个阶乘数;(c)一个平方数;(d)一个立方数,(e)5的倍数
10、本问题的答案是:
(a)a;(b)b;(c)c;(d)d;(e)e。
拉莫斯 发表于 2011-9-5 01:10:45 | 显示全部楼层
今天看到scott说,最好的程序员不是最聪明的人,而是最好的外交家;
现在软件行业招人,有些面试题,,,我就不说了
想起上周active network来的面试,对于影响很大;
回复

使用道具 举报

 楼主| solimh 发表于 2011-9-17 10:40:55 | 显示全部楼层
1、
  1. public class test{
  2. //不是同时打比赛时
  3. public static void main(String[] args){
  4.   String[] s1 = {"a","b","c"};
  5.   String[] s2 = {"x","y","z"};
  6.   for(int i=0;i<s1.length;i++){
  7.    for(int j=0;j<s2.length;j++){
  8.     if ( !(i==0 && j==0) && !(i==2 &&(j==0 || j==2)) ){
  9.      System.out.println(s1[i]+" and " +s2[j]+ " fight!");
  10.     }
  11.    }
  12.   }
  13. }
  14. }
复制代码
-----------------
  1. public class test{
  2. //如果是同时开始比赛的话
  3. String a,b,c;//甲队的
  4. public test(String a,String b,String c){
  5.   this.a=a;
  6.   this.b=b;
  7.   this.c=c;
  8. }
  9. public String toString(){
  10.   return "\n"+"a V.S. "+a+" \n"+"b V.S. "+b+" \n"+"c V.S. "+c;
  11. }
  12. public static void main(String[] args){
  13.   String[] yi = {"x","y","z"};
  14.   ArrayList<test> ar = new ArrayList<test>();
  15.   for(int i=0;i<3;i++){
  16.    for(int j=0;j<3;j++){
  17.     for(int k=0;k<3;k++){
  18.      test t = new test(yi[i],yi[j],yi[k]);
  19.      if(!t.a.equals(t.b) && !t.a.equals(t.c) && !t.b.equals(t.c)
  20.      && !t.a.equals("x") && !t.c.equals("x") && !t.c.equals("z")){
  21.       ar.add(t);
  22.      }
  23.     }
  24.    }
  25.   }
  26.   for(Object obj:ar){
  27.    System.out.println(obj);
  28.   }
  29. }
  30. }
复制代码
回复

使用道具 举报

 楼主| solimh 发表于 2011-9-19 10:24:44 | 显示全部楼层
2、
  1. public class test{
  2. public int encrp(int num){
  3.   int qian = (num/1000+5);
  4.   int bai = (num00/100 +5);
  5.   int shi = (num000/10+5);
  6.   int ge = (num+5);
  7.   return ge*1000+shi*100+bai*10+qian;
  8. }
  9. public static void main(String[] args) throws IOException{
  10.   BufferedReader br = new BufferedReader(new
  11. InputStreamReader(System.in));
  12.   System.out.println("请输入一个四位数:");
  13.   int num = Integer.parseInt(br.readLine());
  14.   System.out.println(new test().encrp(num));
  15. }
  16. }
复制代码
回复

使用道具 举报

 楼主| solimh 发表于 2011-9-20 15:52:52 | 显示全部楼层
3、
  1. public class test{
  2. public double money(int num){
  3.   if(num <=10){
  4.    return num*0.1;
  5.   }else if(num <= 20){
  6.    return 1+(num-10)*0.075;
  7.   }else if(num <= 40){
  8.    return 1.75+(num-20)*0.05;
  9.   }else if(num <= 60){
  10.    return 2.75+(num-40)*0.03;
  11.   }else if(num <= 100){
  12.    return 3.35+(num-60)*0.015;
  13.   }else {
  14.    return 3.95+(num-100)*0.01;
  15.   }
  16. }
  17. public static void main(String[] args) throws IOException{
  18.   System.out.println("请输入当月利润(万元):");
  19.   Scanner sc = new Scanner(System.in);
  20.   System.out.println(new test().money(sc.nextInt()));
  21. }
  22. }
复制代码
回复

使用道具 举报

 楼主| solimh 发表于 2011-9-23 16:26:36 | 显示全部楼层
4、
  1. import java.util.Iterator;
  2. import java.util.LinkedList;
  3. public class test {
  4. // 定义三个String对象
  5. public static final String rabbitName = "猫";
  6. public static final String wolfName = "狗";
  7. public static final String cabbageName = "鱼";
  8. // 判断两个对象之间关系是否友好
  9. public static boolean isFriendly(Goods goods1, Goods goods2) {
  10.   if (goods1 != null) {
  11.    //猫不会和其他两位共存,只能单独
  12.    if (goods1.getGoodsName().trim().equals(rabbitName)) {
  13.     if (goods2 == null) {
  14.      return true;
  15.     } else {
  16.      return false;
  17.     }
  18.     //鱼和狗可以共存
  19.    } else if (goods1.getGoodsName().trim().equals(wolfName)) {
  20.     if (goods2 == null
  21.       || goods2.getGoodsName().trim().equals(cabbageName)) {
  22.      return true;
  23.     } else {
  24.      return false;
  25.     }
  26.      //狗和鱼可以共存
  27.    } else if (goods1.getGoodsName().trim().equals(cabbageName)) {
  28.     if (goods2 == null
  29.       || goods2.getGoodsName().trim().equals(wolfName)) {
  30.      return true;
  31.     } else {
  32.      return false;
  33.     }
  34.     //什么也不是的时候
  35.    } else {
  36.     return false;
  37.    }
  38.   //空无一物的时候是友好的
  39.   } else {
  40.    return true;
  41.   }
  42. }
  43. // test主程序
  44. public static void main(String[] args) {
  45.   //两个列表一个移之前,一个移之后
  46.   boolean isSuccess = false;
  47.   LinkedList<Goods> beforeCrossing = new LinkedList<Goods>();
  48.   LinkedList<Goods> afterCrossing = new LinkedList<Goods>();
  49.   beforeCrossing.add(new Goods(cabbageName));
  50.   beforeCrossing.add(new Goods(rabbitName));
  51.   beforeCrossing.add(new Goods(wolfName));
  52.   //只要没成功就不停的执行
  53.   while (!isSuccess) {
  54.    //取第一个
  55.    Goods goods1 = beforeCrossing.getFirst();
  56.    System.out.println(goods1.getGoodsName() + " 被取走了");
  57.    beforeCrossing.removeFirst();
  58.    //判断是否已经取完
  59.    if (beforeCrossing.isEmpty()) {
  60.     afterCrossing.addLast(goods1);
  61.     isSuccess = true;
  62.     System.out.println("全部移动完毕!");
  63.    } else {
  64.     //没有取完的话,首先看有谁留下了
  65.     Iterator<Goods> it = beforeCrossing.iterator();
  66.     Goods[] beforeCro = new Goods[2];
  67.     for (int i = 0; it.hasNext(); i++) {
  68.      beforeCro[i] = it.next();
  69.      System.out.println(beforeCro[i].getGoodsName() + " 留了下来");
  70.     }
  71.     //看留下的两位是否关系友好,或者是一位,或者没了
  72.     if (isFriendly(beforeCro[0], beforeCro[1])) {
  73.      //留下的友好,且对岸没有时,成功已过去
  74.      if (afterCrossing.isEmpty()) {
  75.       afterCrossing.addLast(goods1);
  76.       System.out.println(goods1.getGoodsName() + " 被成功的放到了对岸");
  77.      //留下的友好,但是对岸已经有东西了,
  78.      } else {
  79.       Goods goods2 = afterCrossing.getFirst();
  80.       //对岸的东西和将要移的东西,是否友好,好则移动
  81.       if (isFriendly(goods1, goods2)) {
  82.        afterCrossing.addLast(goods1);
  83.        System.out.println(goods1.getGoodsName()
  84.          + " 被成功的放到了对岸");
  85.       //对岸的东西和将要移动的东西,不友好,将对岸的东西移回去,并加到末尾去,要移动的留下
  86.       } else {
  87.        beforeCrossing.addLast(goods2);
  88.        afterCrossing.removeFirst();
  89.        System.out.println(goods1.getGoodsName() + " 与 "
  90.          + goods2.getGoodsName() + "并不和睦 于是把 "
  91.          + goods2.getGoodsName() + "带了回来 并将 "
  92.          + goods1.getGoodsName() + " 留了下来");
  93.       }
  94.      }
  95.     } else {
  96.      //留下的两位看来并不友好
  97.      beforeCrossing.addLast(goods1);
  98.      System.out.println("很可惜 留下来的两个东西并不和睦 于是 " + goods1.getGoodsName() + " 又被放了回去");
  99.     }
  100.    }
  101.   }
  102. }
  103. }
  104. // 货物类,动物类什么的,反正方法类似,拷贝的程序
  105. class Goods {
  106. // 货物名称
  107. ∵ String goodsName;
  108. // 默认构造方法
  109. public Goods(String goodsName) {
  110.   this.goodsName = goodsName;
  111. }
  112. // 获得货物名称
  113. public String getGoodsName() {
  114.   return goodsName;
  115. }
  116. }
复制代码
回复

使用道具 举报

 楼主| solimh 发表于 2011-9-27 14:39:52 | 显示全部楼层
5、
  1. public class HuiYi{
  2.    public static void main(String [] args){
  3.       HuiYi.t1();
  4.    }
  5.    ∵ static void t1(){
  6.       for(int a1=1;a1<=2;a1++){
  7.          for(int a2=1;a2<=2;a2++){
  8.             for(int a3=1;a3<=2;a3++){
  9.                for(int a4=1;a4<=2;a4++){
  10.                   for(int a5=1;a5<=2;a5++){
  11.                      for(int a6=1;a6<=2;a6++){
  12.                         
  13.                         if(
  14.                            tm1(a1,a2,a3,a4,a5,a6)
  15.                            && tm2(a1,a2,a3,a4,a5,a6)
  16.                            && tm3(a1,a2,a3,a4,a5,a6)
  17.                            && tm4(a1,a2,a3,a4,a5,a6)
  18.                            && tm5(a1,a2,a3,a4,a5,a6)
  19.                            && tm6(a1,a2,a3,a4,a5,a6)
  20.                         
  21.                         ){
  22.                            

  23. System.out.println"a1="+a1+",a2="+a2+",a3="+a3+",a4="+a4+",a5="+a5+",a6="+a6);
  24.                         }
  25.                         
  26.                         
  27.                      }
  28.                   }
  29.                }
  30.             }
  31.          }
  32.       }
  33.       
  34.    }
  35.    
  36.    ∵ static int countGo(int ... as){
  37.       int sum = 0;
  38.       for(int a : as){
  39.          if(a == 1){
  40.             sum ++;
  41.          }
  42.       }
  43.       
  44.       return sum;
  45.    }
  46.    
  47.    
  48.    ∵ static boolean tm1(int a1,int a2,int a3,int a4,int a5,int a6){
  49.       if(countGo(a1,a2)>=1){
  50.          return true;
  51.       }
  52.       return false;
  53.    }
  54.    ∵ static boolean tm2(int a1,int a2,int a3,int a4,int a5,int a6){
  55.       if(countGo(a1,a5,a6)==2){
  56.          return true;
  57.       }
  58.       return false;
  59.    }
  60.    ∵ static boolean tm3(int a1,int a2,int a3,int a4,int a5,int a6){
  61.       if(countGo(a2,a3)==0 || countGo(a2,a3)==2){
  62.          return true;
  63.       }
  64.       return false;
  65.    }
  66.    ∵ static boolean tm4(int a1,int a2,int a3,int a4,int a5,int a6){
  67.       if(countGo(a1,a4)==1){
  68.          return true;
  69.       }
  70.       return false;
  71.    }
  72.    ∵ static boolean tm5(int a1,int a2,int a3,int a4,int a5,int a6){
  73.       if(countGo(a3,a4)==1){
  74.          return true;
  75.       }
  76.       return false;
  77.    }
  78.    ∵ static boolean tm6(int a1,int a2,int a3,int a4,int a5,int a6){
  79.       if(countGo(a4)==0){
  80.          if(countGo(a5)==0){
  81.             return true;
  82.          }else{
  83.             return false;
  84.          }
  85.       }
  86.       return true;
  87.    }
  88. }
复制代码
回复

使用道具 举报

 楼主| solimh 发表于 2011-9-28 15:09:45 | 显示全部楼层
6、
  1. public class DaoYou{
  2.    public static void main(String args[]){
  3.       DaoYou t = new DaoYou();
  4.       t.t1();
  5.    }
  6.    ∵ void t1(){
  7.       Tong t1 = new Tong();
  8.       t1.max = 10;
  9.       t1.now = 10;
  10.       
  11.       Tong t2 = new Tong();
  12.       t2.max = 7;
  13.       t2.now = 0;
  14.       
  15.       Tong t3 = new Tong();
  16.       t3.max = 3;
  17.       t3.now = 0;
  18.       
  19.       Tong ts[] = new Tong[3];
  20.       ts[0] = t1;
  21.       ts[1] = t2;
  22.       ts[2] = t3;
  23.       
  24.       MySet set = new MySet();
  25.       set.add(ts);
  26.       
  27.       stepDaoYou(set);      
  28.       
  29.       
  30.    }
  31.    int end = 5;
  32.    ∵ void stepDaoYou(MySet setKeNeng){
  33.       for(Object objs : setKeNeng.getAll()){
  34.          Tong ts[] = (Tong[])objs;
  35.          
  36.          //1:判断是否已经已完成
  37.          if(ts[0].now==end || ts[1].now==end || ts[2].now==end){
  38.             System.out.println("倒油完成---"+ts[0].now+","+ts[1].now+","+ts[2].now);
  39.             break;
  40.          }
  41.          //2:递归
  42.          stepDaoYou(keNengDaoYou(ts));         
  43.       }
  44.       
  45.    }
  46.    
  47.    MySet yiDao = new MySet();
  48.       
  49.    ∵ MySet keNengDaoYou(Tong [] ts){
  50.       MySet setKeNeng = new MySet();
  51.       System.out.println("A=="+ts[0].now+",B=="+ts[1].now+",C=="+ts[2].now);
  52.       for(int i=0;i<ts.length;i++){
  53.          for(int j=0;j<ts.length;j++){
  54.             //1:不能自己给自己倒
  55.             if(i==j){
  56.                continue;
  57.             }
  58.             //2:算出能倒多少
  59.             int canDaoYou = ts[i].canOut();
  60.             if(ts[i].canOut() > ts[j].canIn()){
  61.                canDaoYou = ts[j].canIn();
  62.             }
  63.             //3:模拟倒
  64.             ts[i].out(canDaoYou);
  65.             ts[j].in(canDaoYou);
  66.             //4:判断这个倒油的步骤是否已经出现过了
  67.             if(yiDao.contains("A="+ts[0].now+",B="+ts[1].now+",C="+ts[2].now)){
  68.                //已经出现了,不能这么倒,否则就死循环了
  69.                //还回去
  70.                ts[i].in(canDaoYou);
  71.                ts[j].out(canDaoYou);
  72.                //
  73.                continue;
  74.             }
  75.             //5:说明可以这么倒油
  76.             //5.1:先在已倒里面加入新的可能的倒油情况
  77.             yiDao.add("A="+ts[0].now+",B="+ts[1].now+",C="+ts[2].now);      
  78.             //5.2添加可能性
  79.             Tong newTs[] = new Tong[3];
  80.             Tong t1 = new Tong();
  81.             t1.max = ts[0].max;
  82.             t1.now = ts[0].now;
  83.             
  84.             Tong t2 = new Tong();
  85.             t2.max = ts[1].max;
  86.             t2.now = ts[1].now;
  87.             
  88.             Tong t3 = new Tong();
  89.             t3.max = ts[2].max;
  90.             t3.now = ts[2].now;
  91.             
  92.             newTs[0] = t1;
  93.             newTs[1] = t2;
  94.             newTs[2] = t3;
  95.          
  96.             System.out.println("keneng------------------>"+"A="+ts[0].now+",B="+ts[1].now+",C="+ts[2].now);   
  97.             setKeNeng.add(newTs);
  98.             
  99.             //6:把油还回去
  100.             ts[i].in(canDaoYou);
  101.             ts[j].out(canDaoYou);
  102.          }
  103.       }      
  104.       return setKeNeng;      
  105.    }
  106.       
  107. }

  108. class Tong{
  109.    //最大值
  110.    public int max = 0;
  111.    //当前值
  112.    public int now = 0;
  113.    
  114.    public void in(int a){
  115.       now += a;
  116.    }
  117.    public void out(int a){
  118.       now -=a;
  119.    }
  120.    
  121.    public int canIn(){
  122.       return (max - now);
  123.    }
  124.    public int canOut(){
  125.       return now;
  126.    }   
  127. }
复制代码
回复

使用道具 举报

 楼主| solimh 发表于 2011-9-30 13:57:45 | 显示全部楼层
7、
  1. public class MaYi{
  2.    public static void main(String [] args){
  3.       MaYi t = new MaYi();
  4.       t.t1();
  5.    }
  6.    ∵ void t1(){
  7.       Ant a1 = new Ant();
  8.       Ant a2 = new Ant();
  9.       Ant a3 = new Ant();
  10.       Ant a4 = new Ant();
  11.       Ant a5 = new Ant();
  12.       
  13.       for(int i=1;i<=2;i++){
  14.          for(int j=1;j<=2;j++){
  15.             for(int k=1;k<=2;k++){
  16.                for(int m=1;m<=2;m++){
  17.                   for(int n=1;n<=2;n++){
  18.                      //做蚂蚁的初始化
  19.                      a1.direct = i;
  20.                      a1.site = 3;   
  21.                      a1.alreadyGone = false;                  
  22.                      a2.direct = j;
  23.                      a2.site = 7;                     
  24.                      a2.alreadyGone = false;
  25.                      a3.direct = k;
  26.                      a3.site = 11;                     
  27.                      a3.alreadyGone = false;
  28.                      a4.direct = m;
  29.                      a4.site = 17;                     
  30.                      a4.alreadyGone = false;
  31.                      a5.direct = n;
  32.                      a5.site = 23;      
  33.                      a5.alreadyGone = false;
  34.                      
  35.                      for(int p=1;p<1000;p++){
  36.                         //1:让蚂蚁走,每次走一步
  37.                         if(!a1.alreadyGone){
  38.                            a1.step();
  39.                         }
  40.                         if(!a2.alreadyGone){
  41.                            a2.step();
  42.                         }
  43.                         if(!a3.alreadyGone){
  44.                            a3.step();
  45.                         }
  46.                         if(!a4.alreadyGone){
  47.                            a4.step();
  48.                         }
  49.                         if(!a5.alreadyGone){
  50.                            a5.step();
  51.                         }
  52.                         //2:判断两只蚂蚁是否会碰头,碰头就都调头
  53.                         if(a1.site==a2.site && a1.direct==2 && a2.direct==1){
  54.                            //1和2碰头了
  55.                            a1.changeDirect();
  56.                            a2.changeDirect();
  57.                         }
  58.                         if(a2.site==a3.site && a2.direct==2 && a3.direct==1){
  59.                            a2.changeDirect();
  60.                            a3.changeDirect();
  61.                         }
  62.                         if(a3.site==a4.site && a3.direct==2 && a4.direct==1){
  63.                            a3.changeDirect();
  64.                            a4.changeDirect();
  65.                         }
  66.                         if(a4.site==a5.site && a4.direct==2 && a5.direct==1){
  67.                            a4.changeDirect();
  68.                            a5.changeDirect();
  69.                         }
  70.                         //3:判断是否已经全部离开
  71.                         if(a1.alreadyGone && a2.alreadyGone && a3.alreadyGone && a4.alreadyGone && a5.alreadyGone){
  72.                            System.out.println("Over===="+p);
  73.                            break;
  74.                         }                        
  75.                      }
  76.                   }
  77.                }
  78.             }
  79.          }
  80.       }
  81.    }      
  82. }

  83. class Ant{
  84.    //用来表示蚂蚁所在的位置
  85.    public int site = 0;
  86.    //表示蚂蚁的朝向,1表示向左,2表示向右
  87.    public int direct = 1;
  88.    //表示蚂蚁已经离开木杆
  89.    public boolean alreadyGone = false;
  90.    
  91.    public void step(){
  92.       if(direct==1){
  93.          site = site - 1;
  94.       }else{
  95.          site = site + 1;
  96.       }
  97.       if(site==0 || site==27){
  98.          alreadyGone = true;
  99.       }      
  100.    }
  101.    
  102.    public void changeDirect(){
  103.       if(direct==1){
  104.          direct = 2;
  105.       }else{
  106.          direct = 1;
  107.       }      
  108.    }
  109. }
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 快速注册

本版积分规则

快速回复 返回顶部 返回列表