import java.util.*;public class TEST{?? public static void main(String[]args)? {?? Scanner sc=new Scanner(System.in);?? int n=sc.nextInt();?? int a[]=new int [n];?? for( int i=0;i<a.length;i++)?? {??? a[i]=i+1;?? }?? int number=a.length;?? int count=0;??while(number>0)??{???for(int i=0;i<a.length;i++)???{????if(a[i]!=-1)????{?????count++;????}????if(count==3)????{?count=0;?????a[i]=-1;?????number--;????}????if(number==0)????{?????System.out.println(a[i]);????}???}??}? }}我實(shí)在想不出為什么輸入6,會(huì)打出6個(gè)-1? 輸入3為什么打出2個(gè)-1?還有就是eclipse是怎么調(diào)試debug的我雙擊代碼左邊后點(diǎn)上面的debug按鈕沒(méi)反應(yīng)
java中約瑟夫問(wèn)題?我的代碼為什么會(huì)打出六個(gè)-1?
qq_Decisivem_0
2017-11-08 10:23:53