Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.LinkedList;
- import java.util.Random;
- public class alternada {
- public static void main(String[] args) {
- Random r= new Random();
- LinkedList cola1= new LinkedList();
- LinkedList cola2= new LinkedList();
- LinkedList unionCola= new LinkedList();
- int nu1= r.nextInt(30);
- int nu2= r.nextInt(30);
- for(int i=1;i<4;i++) {
- nu1=r.nextInt(30);
- cola1.add(nu1);
- nu2=r.nextInt(30);
- cola2.add(nu2);
- System.out.println("numeros primera lista "+ nu1);
- System.out.println("numeros segunda lista "+ nu2);
- }
- while(cola1.size()>0 & cola2.size()>0) {
- unionCola.add((int) cola1.remove());
- unionCola.add((int) cola2.remove());
- }
- while( unionCola.size()>0 ){
- System.out.println("Dato: "+(int) unionCola.remove());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement