From 9a162c4a1010f73fb516e940b6b7f2215c9033ce Mon Sep 17 00:00:00 2001 From: pnevmoslon1 Date: Tue, 12 Mar 2024 16:05:56 -0700 Subject: [PATCH] 123 --- .gitignore | 29 +++++++++++++++++++++++ .idea/.gitignore | 3 +++ .idea/misc.xml | 6 +++++ .idea/modules.xml | 8 +++++++ .idea/vcs.xml | 6 +++++ AiSD_lab1.iml | 11 +++++++++ src/InsertionSort.java | 0 src/Main.java | 47 ++++++++++++++++++++++++++++++++++++++ src/Node.java | 19 +++++++++++++++ src/QueueOnLinkedlist.java | 20 ++++++++++++++++ 10 files changed, 149 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 AiSD_lab1.iml create mode 100644 src/InsertionSort.java create mode 100644 src/Main.java create mode 100644 src/Node.java create mode 100644 src/QueueOnLinkedlist.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6f29fee --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..346bf6d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/AiSD_lab1.iml b/AiSD_lab1.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/AiSD_lab1.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/InsertionSort.java b/src/InsertionSort.java new file mode 100644 index 0000000..e69de29 diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..f613146 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,47 @@ +import java.util.Scanner; + + + + + +public class Main { + + public static void main(String[] args) { + + +// Scanner b = new Scanner(System.in); +// QueueOnLinkedlist a = new QueueOnLinkedlist(); +// for (int i = 0; i < 5; i++) { +// a.add(b.nextLine()); +// } +// +// System.out.println(a.peek()); + + int[] arr = new int[10]; + for (int i = 9; i >= 0; i--){ + arr[9 - i] = i; + } + + + + int n = arr.length; + for (int i = 1; i < n; ++i) { + int key = arr[i]; + int j = i - 1; + + + while (j >= 0 && arr[j] > key) { + arr[j + 1] = arr[j]; + j = j - 1; + } + arr[j + 1] = key; + } + + + + + for (int i = 0; i < arr.length; i++){ + System.out.print(arr[i] + " "); + } + } +} \ No newline at end of file diff --git a/src/Node.java b/src/Node.java new file mode 100644 index 0000000..644d2a4 --- /dev/null +++ b/src/Node.java @@ -0,0 +1,19 @@ +public class Node { + private T value; + private Node next; + public T getValue() { + return value; + } + + public void setValue(T value) { + this.value = value; + } + + public Node getNext() { + return next; + } + + public void setNext(Node next) { + this.next = next; + } +} diff --git a/src/QueueOnLinkedlist.java b/src/QueueOnLinkedlist.java new file mode 100644 index 0000000..abadb5d --- /dev/null +++ b/src/QueueOnLinkedlist.java @@ -0,0 +1,20 @@ +import java.util.LinkedList; +public class QueueOnLinkedlist { + + private LinkedList queuee = new LinkedList<>(); + + public void add (String s){ + queuee.add(s); + } + public String peek (){ + return queuee.peekFirst(); + } + public void pop (){ + queuee.removeFirst(); + } + public void printQueue(){ + for (String element : queuee) { + System.out.println(element); + } + } +}