Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class EvTapsirigi2_1 {
- static Queue<Integer> qe = new LinkedList<>();
- static Scanner sc = new Scanner(System.in);
- public static void main(String[] args) {
- boolean check = true;
- int choice;
- while (check) {
- choice = choice("1.Ədəd daxil edin\r\n" + "2.Ədəd silin\r\n" + "3.Öndəki ədədi göstər\r\n"
- + "4.Ədədləri göstər\r\n" + "5.Çıxış\r\n");
- operations(choice);
- if (choice == 5)
- check = false;
- }
- }
- public static void operations(int n) {
- switch (n) {
- case 1:
- System.out.print("Daxil edəcəyiniz ədədlərin sayı: ");
- int size = sc.nextInt();
- System.out.print("Ədəd(lər)i daxil edin: ");
- for (int i = 0; i < size; i++) {
- int input = sc.nextInt();
- qe.offer(input);
- System.out.println(input + " əlavə edildi!\n");
- }
- break;
- case 2:
- qe.poll();
- System.out.println("Silindi!");
- System.out.println(qe);
- break;
- case 3:
- System.out.print("Birinci indeksdəki ədəd: ");
- System.out.println(qe.peek());
- System.out.println("\n");
- break;
- case 4:
- System.out.println(qe);
- break;
- case 5:
- System.out.println("Proqram qapadılır...\n");
- break;
- }
- }
- public static int choice(String title) {
- System.out.println(title);
- int answer = sc.nextInt();
- return answer;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement