Herowaree

r

Nov 25th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. public class TesteFila {
  2. public static void main(String []args){
  3. Fila fila = new Fila();
  4. Scanner input = new Scanner(System.in);
  5.  
  6. int array[] = new int[55];
  7. int N;
  8.  
  9. while(true){
  10. N = input.nextInt();
  11.  
  12. if(N == 0) break;
  13.  
  14. int count;
  15. for(count = 1; count <= N; count++){
  16. fila.insereFila(count);
  17. }
  18.  
  19. int aux = 0;
  20. while(fila.getTamanho() >= 2){
  21. array[aux] = fila.removeFila();
  22. aux++;
  23. fila.insereFila(fila.removeFila());
  24. }
  25.  
  26. System.out.printf("Discarded cards: ");
  27. for(count = 0; count < aux; count++){
  28. System.out.printf("%d", array[count]);
  29. if(count < aux - 1){
  30. System.out.printf(", ");
  31. }
  32. }
  33. System.out.println();
  34.  
  35. System.out.println("Remaining card: " + fila.removeFila());
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment