import java.util.Scanner; public class Main{ public static void main(String[]args) { Scanner input=new Scanner(System.in); int n= input.nextInt(); int m= input.nextInt(); int []ant=new int[150]; for(int i=1;i<=n-1;i++) { ant[i]=i+1; } ant[n]=1; int now=1; int prev=1; while(n-->0) { for(int i=1;i<m;i++) { prev=now; now=ant[now]; } System.out.print(now+" "); ant[prev]=ant[now]; now=ant[prev]; } //System.out.print(now); } }
标签:单链,Scanner,int,nextInt,解题,new,input,---&,public From: https://www.cnblogs.com/liliczw2209/p/17308175.html