Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.management.Query;
- import java.io.*;
- import java.util.*;
- public class Main {
- public static void main(String[] args) throws FileNotFoundException {
- Scanner in = new Scanner(new File("input.txt"));
- PrintWriter pw = new PrintWriter("output.txt");
- Queue<Integer> queue = new LinkedList<>();
- String a;
- do {
- a = in.next();
- switch (a) {
- case "push":
- queue.add(in.nextInt());
- pw.println("ok");
- break;
- case "pop":
- if (queue.size() == 0) pw.println("error");
- else pw.println(queue.poll());
- break;
- case "front":
- if (queue.size() == 0) pw.println("error");
- else pw.println(queue.peek());
- break;
- case "size":
- pw.println(queue.size());
- break;
- case "clear":
- queue.clear();
- pw.println("ok");
- break;
- }
- } while (!a.equals("exit"));
- pw.println("bye");
- in.close();
- pw.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement