Advertisement
Latkoski

Консултации(бројач)

May 29th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1. package Konsultacii;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.ArrayDeque;
  7.  
  8. public class Konsultacii {
  9.     public static void main(String[] args) throws NumberFormatException, IOException {
  10.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  11.         ArrayDeque<Student> aps = new ArrayDeque<Student>();
  12.         ArrayDeque<String> mms = new ArrayDeque<String>();
  13.         int broj_aps = Integer.parseInt(br.readLine());
  14.         int brojac = 0;
  15.         for (int i = 0; i < broj_aps; i++) {
  16.             String[] student_podelen = br.readLine().split(" ");
  17.             Student st = new Student(student_podelen[0], student_podelen[1]);
  18.             aps.add(st);
  19.         }
  20.         int broj_mms = Integer.parseInt(br.readLine());
  21.         for (int i = 0; i < broj_mms; i++)
  22.             mms.add(br.readLine());
  23.  
  24.         String temp = null;
  25.         while (!aps.isEmpty()) {
  26.             Student st = aps.poll();
  27.             if (!st.tip.equals(temp)) {
  28.                 temp = st.tip;
  29.                 System.out.println(st.ime);
  30.  
  31.             } else if (st.tip.equals(temp)) {
  32.                 brojac++;
  33.                 if (brojac > 3) {
  34.                     brojac = 0;
  35.                     System.out.println(st.ime);
  36.                 } else
  37.                     aps.add(st);
  38.                 if (!mms.isEmpty())
  39.                     System.out.println(mms.poll());
  40.             }
  41.  
  42.         }
  43.  
  44.     }
  45.  
  46. }
  47.  
  48. class Student {
  49.     public String ime;
  50.     public String tip;
  51.  
  52.     public Student(String ime, String tip) {
  53.         this.ime = ime;
  54.         this.tip = tip;
  55.     }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement