0

我试图创建一个程序,以便能够创建一个包含所有可用团队组合的组,比如说我将从组数组列表中获得的 3 个整数。到目前为止,我已经来到了这个状态

public static Integer organzieGroups(int groupSize,int teamSize) {
            Random rand =new Random();
        int count=0;
        ArrayList<Integer> group = new ArrayList<Integer>(groupSize);
    for (int i = 0; i <groupSize; i++) { 
        Integer r =rand.nextInt(groupSize);
        group.add(r);

        }
    System.out.println(" Just added and populated the group arraylist");
        ArrayList<Integer> team  = new ArrayList<Integer>(teamSize);

        int loopTimes=groupSize;
        Integer e=0;
        int i=0;
        int s=0;                
            for(i=0; i<loopTimes-1 ; i++){
                s=i+count;
                e = group.get(i)+ (group.get(i+1));
                System.out.println(e);
            }
            count++;
            loopTimes--;
            System.out.println(count + " " + loopTimes);

            if(count>loopTimes) {
                System.out.println("Solution Found");
                return e;
            }
            else
            {   System.out.println("Recursion Call");
                showTeams(groupSize,teamSize);
            }
            return e;
        }
        public static void main(String[] args) {

            Scanner siseInput= new Scanner(System.in);
            int groupSize;
            int teamSize;
                System.out.println("Type the group size you wish to create ");
                    groupSize= siseInput.nextInt();
                System.out.println(" The group will be of size : "+groupSize);
                System.out.println("Type the team size you wish to create ");
                    teamSize= siseInput.nextInt();
                System.out.println(" The team will be of size : "+teamSize);            
                        showTeams(groupSize,teamSize);
        }

}

关于如何继续或我是否走错路的任何想法?

4

0 回答 0