import java.util.*;
public class n00883428
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
{
int i;
int j;
int numPeople;
int numCount;
int upTo = 0;
long memory;
long startTime;
long endTime;
System.out.print("How many people are in the circle?");
numPeople = in.nextInt();
System.out.print("Enter number to count out of circle:");
numCount = in.nextInt();
int men[] = new int[numPeople];
System.out.print("Order of Elimination:");
for(i = 1; i < numPeople; i++)
men[i] = i + 1;
startTime = System.currentTimeMillis();
while(numPeople > 1)
{
upTo = (upTo + numCount) % numPeople;
System.out.print(men[upTo] + " ");
numPeople--;
for(j = upTo; j < numPeople; j++)
men[j] = men[j + 1];
}
System.out.println("\nNumer " +men[0] +" will be left");
}
}
}
startTime = System.currentTimeMillis();
while(numPeople > 1)
{
upTo = (upTo + numCount) % numPeople;
System.out.print(men[upTo] + " ");
numPeople--;
for(j = upTo; j < numPeople; j++)
men[j] = men[j + 1];
}
System.out.println("\nNumer " +men[0] +" will be left");
}
}
}
troval 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.