有一组人 A B C D E F G
每天必须两人打扫卫生, 如 AB,CD,EF,GA这样循环下去,有谁能给个好点的算法
谢了!

解决方案 »

  1.   

    this is a problem of scheduling. 
    If there is no special constraints on the schedule, you can just follow a sequential schedule.
      

  2.   

    // try this  :-)
    public class T {
       public static void main(String[] args) {
          String a = "ABCDEFG";
          int len = a.length();
          int first = 0,second = 1;
          do {
             System.out.println(""+a.charAt(first)+a.charAt(second));
             first = (first+2) % len; second = (second+2) % len;
          } while(first != 0 &&second != 1);
       }
    }