Advertisement
Guest User

Untitled

a guest
May 25th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.88 KB | None | 0 0
  1. class DrugeVezbe{
  2.   public static void main(String[] args){
  3.     Red<String> red = new Red<String>();
  4.     while (!red.jePun() && Svetovid.in("r1.txt").hasMore()){
  5.       String tek = Svetovid.in("r1.txt").readLine();
  6.       red.naKraj(tek);
  7.     }
  8.     System.out.println(red);
  9.     System.out.println();
  10.    
  11.     while (red.prvi().length() < 6){
  12.         red.izbaciPrvi();
  13.     }
  14.    
  15.     System.out.println("U koji fajl zelite da smestite red opsluzivanja?");
  16.     String noviFajl = Svetovid.in.readLine();
  17.     while (!red.jePrazan()){
  18.       Svetovid.out(noviFajl + ".txt").println(red.prvi());
  19.       red.izbaciPrvi();
  20.     }
  21.     Svetovid.out(noviFajl + ".txt").close();
  22.  
  23.  
  24.     // 2)
  25.     Stek<Integer> prvi = new Stek<Integer>();
  26.     Stek<Integer> drugi = new Stek<Integer>();
  27.     while (Svetovid.in("p1.txt").hasMore()){
  28.       int tek = Svetovid.in("p1.txt").readInt();
  29.       prvi.stavi(tek);
  30.     }
  31.     Svetovid.in("p1.txt").close();
  32.     System.out.println("Prvi stek: " + prvi);
  33.     while (Svetovid.in("p2.txt").hasMore()){
  34.       int tek = Svetovid.in("p2.txt").readInt();
  35.       drugi.stavi(tek);
  36.     }
  37.     Svetovid.in("p2.txt").close();
  38.     System.out.println("Drugi stek: " + drugi);
  39.       // b)
  40.     while (!prvi.jePrazan() && prvi.vrh() <= 9){
  41.       prvi.skiniVrh();
  42.     }
  43.       // c)
  44.     while (!drugi.jePrazan() && drugi.vrh() % 2 == 1){
  45.       drugi.skiniVrh();
  46.     }
  47.    
  48.       // d)
  49.     Stek<Integer> treci = new Stek<Integer>();
  50.     while (!prvi.jePrazan() && !drugi.jePrazan()){
  51.       treci.stavi(prvi.skiniVrh());
  52.       treci.stavi(drugi.skiniVrh());
  53.     }
  54.     while (!prvi.jePrazan()){
  55.       treci.stavi(prvi.skiniVrh());
  56.     }
  57.     while (!drugi.jePrazan()){
  58.       treci.stavi(drugi.skiniVrh());
  59.     }
  60.    
  61.       // e)
  62.     while (!treci.jePrazan()){
  63.       Svetovid.out("pp.txt").println(treci.skiniVrh());
  64.     }
  65.     Svetovid.out("pp.txt").close();
  66.   }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement