Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TesteFila {
- public static void main(String []args){
- Fila fila = new Fila();
- Scanner input = new Scanner(System.in);
- int array[] = new int[55];
- int N;
- while(true){
- N = input.nextInt();
- if(N == 0) break;
- int count;
- for(count = 1; count <= N; count++){
- fila.insereFila(count);
- }
- int aux = 0;
- while(fila.getTamanho() >= 2){
- array[aux] = fila.removeFila();
- aux++;
- fila.insereFila(fila.removeFila());
- }
- System.out.printf("Discarded cards: ");
- for(count = 0; count < aux; count++){
- System.out.printf("%d", array[count]);
- if(count < aux - 1){
- System.out.printf(", ");
- }
- }
- System.out.println();
- System.out.println("Remaining card: " + fila.removeFila());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment