From c79abcfba31f6ee452692b65b0a9ae5a2f9511dc Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:32:33 +0530 Subject: [PATCH 01/27] Rename ArrayList.java to java/ArrayList.java --- ArrayList.java => java/ArrayList.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ArrayList.java => java/ArrayList.java (100%) diff --git a/ArrayList.java b/java/ArrayList.java similarity index 100% rename from ArrayList.java rename to java/ArrayList.java From 8d122d6b23fcefb7e02106921b6f3543d0f17821 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:32:55 +0530 Subject: [PATCH 02/27] Rename BinarySearch.java to java/BinarySearch.java --- BinarySearch.java => java/BinarySearch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename BinarySearch.java => java/BinarySearch.java (99%) diff --git a/BinarySearch.java b/java/BinarySearch.java similarity index 99% rename from BinarySearch.java rename to java/BinarySearch.java index 5a68bf7..e0ec13e 100644 --- a/BinarySearch.java +++ b/java/BinarySearch.java @@ -24,4 +24,4 @@ public static void main(String args[]){ int last=arr.length-1; binarySearch(arr,0,last,key); } -} \ No newline at end of file +} From 37107dd8440b92d5b11c7aa24fde4cc93afdbe6a Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:33:14 +0530 Subject: [PATCH 03/27] Rename Bogo_sort.java to java/Bogo_sort.java --- Bogo_sort.java => java/Bogo_sort.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Bogo_sort.java => java/Bogo_sort.java (100%) diff --git a/Bogo_sort.java b/java/Bogo_sort.java similarity index 100% rename from Bogo_sort.java rename to java/Bogo_sort.java From 3c67cc9d9ad896b610e7b04b6e9ee00a7de4c51c Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:33:33 +0530 Subject: [PATCH 04/27] Rename Calculator.java to java/Calculator.java --- Calculator.java => java/Calculator.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Calculator.java => java/Calculator.java (100%) diff --git a/Calculator.java b/java/Calculator.java similarity index 100% rename from Calculator.java rename to java/Calculator.java From 6a12d41a1bc825beacbb5e4f67c6d828d12a2a28 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:33:50 +0530 Subject: [PATCH 05/27] Rename CrudCurrencyConvertor.java to java/CrudCurrencyConvertor.java --- CrudCurrencyConvertor.java => java/CrudCurrencyConvertor.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CrudCurrencyConvertor.java => java/CrudCurrencyConvertor.java (100%) diff --git a/CrudCurrencyConvertor.java b/java/CrudCurrencyConvertor.java similarity index 100% rename from CrudCurrencyConvertor.java rename to java/CrudCurrencyConvertor.java From 0dca8d5a608bf61851b411d2f904766b82955881 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:34:22 +0530 Subject: [PATCH 06/27] Rename GuessTheNumberGame.java to java/GuessTheNumberGame.java --- GuessTheNumberGame.java => java/GuessTheNumberGame.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename GuessTheNumberGame.java => java/GuessTheNumberGame.java (100%) diff --git a/GuessTheNumberGame.java b/java/GuessTheNumberGame.java similarity index 100% rename from GuessTheNumberGame.java rename to java/GuessTheNumberGame.java From f1f143a6e4b02f540003a6a401b4f0ebadb2c922 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:34:42 +0530 Subject: [PATCH 07/27] Rename Heap_Sort.java to java/Heap_Sort.java --- Heap_Sort.java => java/Heap_Sort.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Heap_Sort.java => java/Heap_Sort.java (100%) diff --git a/Heap_Sort.java b/java/Heap_Sort.java similarity index 100% rename from Heap_Sort.java rename to java/Heap_Sort.java From 5f1ca28820d1b5f6d037503433a64279c9e88a90 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:35:03 +0530 Subject: [PATCH 08/27] Rename Linked_list.java to java/Linked_list.java --- Linked_list.java => java/Linked_list.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Linked_list.java => java/Linked_list.java (96%) diff --git a/Linked_list.java b/java/Linked_list.java similarity index 96% rename from Linked_list.java rename to java/Linked_list.java index 4dcd66a..36da173 100644 --- a/Linked_list.java +++ b/java/Linked_list.java @@ -64,4 +64,4 @@ public static void main(String[] args) { //Displays the nodes present in the list sList.display(); } -} \ No newline at end of file +} From 8c6c02591c8b9e8009446031f3959ba83cfba9a9 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:35:23 +0530 Subject: [PATCH 09/27] Rename InsertionSort.java to java/InsertionSort.java --- InsertionSort.java => java/InsertionSort.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename InsertionSort.java => java/InsertionSort.java (100%) diff --git a/InsertionSort.java b/java/InsertionSort.java similarity index 100% rename from InsertionSort.java rename to java/InsertionSort.java From 9b842696798a7c04b44fb5d5b1b23d17ddf12e68 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:35:40 +0530 Subject: [PATCH 10/27] Rename warshall.java to java/warshall.java --- warshall.java => java/warshall.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename warshall.java => java/warshall.java (100%) diff --git a/warshall.java b/java/warshall.java similarity index 100% rename from warshall.java rename to java/warshall.java From 01ebf7af2c5433356f934175e458f36e44d67cc0 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:35:56 +0530 Subject: [PATCH 11/27] Rename secondlargest.java to java/secondlargest.java --- secondlargest.java => java/secondlargest.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename secondlargest.java => java/secondlargest.java (100%) diff --git a/secondlargest.java b/java/secondlargest.java similarity index 100% rename from secondlargest.java rename to java/secondlargest.java From 7bb53ed597716af5eb955938bd28dac386a326e0 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:36:14 +0530 Subject: [PATCH 12/27] Rename reverseLinkedList.java to java/reverseLinkedList.java --- reverseLinkedList.java => java/reverseLinkedList.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename reverseLinkedList.java => java/reverseLinkedList.java (100%) diff --git a/reverseLinkedList.java b/java/reverseLinkedList.java similarity index 100% rename from reverseLinkedList.java rename to java/reverseLinkedList.java From 7b4a0c87fb4938ff05e7162197b1116f9ad882b3 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:36:31 +0530 Subject: [PATCH 13/27] Rename QuickSort.java to java/QuickSort.java --- QuickSort.java => java/QuickSort.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename QuickSort.java => java/QuickSort.java (99%) diff --git a/QuickSort.java b/java/QuickSort.java similarity index 99% rename from QuickSort.java rename to java/QuickSort.java index 1bf17c3..bcea725 100644 --- a/QuickSort.java +++ b/java/QuickSort.java @@ -59,4 +59,4 @@ public static void main(String[] args) System.out.println("Sorted array: "); printArray(arr, n); } -} \ No newline at end of file +} From 8557ef907f694523d56b72a1d6141e20f783ea0d Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:36:52 +0530 Subject: [PATCH 14/27] Rename LongestPath.java to java/LongestPath.java --- LongestPath.java => java/LongestPath.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LongestPath.java => java/LongestPath.java (100%) diff --git a/LongestPath.java b/java/LongestPath.java similarity index 100% rename from LongestPath.java rename to java/LongestPath.java From 7292f7f82fd1e16e6041f60b559b2ead57763ca1 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:37:15 +0530 Subject: [PATCH 15/27] Rename SelectionSort.java to java/SelectionSort.java --- SelectionSort.java => java/SelectionSort.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename SelectionSort.java => java/SelectionSort.java (100%) diff --git a/SelectionSort.java b/java/SelectionSort.java similarity index 100% rename from SelectionSort.java rename to java/SelectionSort.java From ffe7ed2b4d204d4fc48cd6ca1ded46b667e99790 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:37:34 +0530 Subject: [PATCH 16/27] Rename fibonacci_series.java to java/fibonacci_series.java --- fibonacci_series.java => java/fibonacci_series.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename fibonacci_series.java => java/fibonacci_series.java (100%) diff --git a/fibonacci_series.java b/java/fibonacci_series.java similarity index 100% rename from fibonacci_series.java rename to java/fibonacci_series.java From 0a2b508b90db36231e7c92b22c21f10c85a0eac8 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:37:52 +0530 Subject: [PATCH 17/27] Rename palindro.java to java/palindro.java --- palindro.java => java/palindro.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename palindro.java => java/palindro.java (100%) diff --git a/palindro.java b/java/palindro.java similarity index 100% rename from palindro.java rename to java/palindro.java From 5f4f51e37f6555ee05aae311ec1a6f61904b13f4 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:38:14 +0530 Subject: [PATCH 18/27] Rename palindrome.java to java/palindrome.java --- palindrome.java => java/palindrome.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename palindrome.java => java/palindrome.java (100%) diff --git a/palindrome.java b/java/palindrome.java similarity index 100% rename from palindrome.java rename to java/palindrome.java From 880b9400640b9b691c152410da8df53306ba14f6 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:38:32 +0530 Subject: [PATCH 19/27] Rename nextGreaterElement_stack.java to java/nextGreaterElement_stack.java --- .../nextGreaterElement_stack.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename nextGreaterElement_stack.java => java/nextGreaterElement_stack.java (100%) diff --git a/nextGreaterElement_stack.java b/java/nextGreaterElement_stack.java similarity index 100% rename from nextGreaterElement_stack.java rename to java/nextGreaterElement_stack.java From 27c55c13b4376f865c00d9834c33a03b917affac Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:38:51 +0530 Subject: [PATCH 20/27] Rename emirp.java to java/emirp.java --- emirp.java => java/emirp.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename emirp.java => java/emirp.java (100%) diff --git a/emirp.java b/java/emirp.java similarity index 100% rename from emirp.java rename to java/emirp.java From 8ceb6d91703c4974268d37f9ed130255867d6a72 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:39:07 +0530 Subject: [PATCH 21/27] Rename bubbleSort.java to java/bubbleSort.java --- bubbleSort.java => java/bubbleSort.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bubbleSort.java => java/bubbleSort.java (100%) diff --git a/bubbleSort.java b/java/bubbleSort.java similarity index 100% rename from bubbleSort.java rename to java/bubbleSort.java From 298829fb593f9be388a26e9f70f47a73acf278ff Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:39:27 +0530 Subject: [PATCH 22/27] Rename SortHeap.java to java/SortHeap.java --- SortHeap.java => java/SortHeap.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename SortHeap.java => java/SortHeap.java (100%) diff --git a/SortHeap.java b/java/SortHeap.java similarity index 100% rename from SortHeap.java rename to java/SortHeap.java From e3b7bd24c0ab6e28184ed1a0e63ac42ced469bdf Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:39:57 +0530 Subject: [PATCH 23/27] Rename Rock-Paper-scissors game to java/Rock-Paper-scissors game.java --- Rock-Paper-scissors game => java/Rock-Paper-scissors game.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Rock-Paper-scissors game => java/Rock-Paper-scissors game.java (100%) diff --git a/Rock-Paper-scissors game b/java/Rock-Paper-scissors game.java similarity index 100% rename from Rock-Paper-scissors game rename to java/Rock-Paper-scissors game.java From 06467dbcd7208a814b85528b1b1560c7d1b5cce6 Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:40:15 +0530 Subject: [PATCH 24/27] Rename StringBuilderQuestions.java to java/StringBuilderQuestions.java --- StringBuilderQuestions.java => java/StringBuilderQuestions.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename StringBuilderQuestions.java => java/StringBuilderQuestions.java (100%) diff --git a/StringBuilderQuestions.java b/java/StringBuilderQuestions.java similarity index 100% rename from StringBuilderQuestions.java rename to java/StringBuilderQuestions.java From faafd640ebaf2d6b252d5e84de2d13eeb078729b Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:40:31 +0530 Subject: [PATCH 25/27] Rename Transpose Matrix.java to java/Transpose Matrix.java --- Transpose Matrix.java => java/Transpose Matrix.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Transpose Matrix.java => java/Transpose Matrix.java (99%) diff --git a/Transpose Matrix.java b/java/Transpose Matrix.java similarity index 99% rename from Transpose Matrix.java rename to java/Transpose Matrix.java index 9193379..44722d2 100644 --- a/Transpose Matrix.java +++ b/java/Transpose Matrix.java @@ -12,4 +12,4 @@ public int[][] transpose(int[][] matrix) { return arr; } -} \ No newline at end of file +} From 38ad9d19d3202d92680191f8bbcd03620b5f566a Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:40:51 +0530 Subject: [PATCH 26/27] Rename DFS.cpp to C++/DFS.cpp --- DFS.cpp => C++/DFS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename DFS.cpp => C++/DFS.cpp (99%) diff --git a/DFS.cpp b/C++/DFS.cpp similarity index 99% rename from DFS.cpp rename to C++/DFS.cpp index 824e652..5d0b5d9 100644 --- a/DFS.cpp +++ b/C++/DFS.cpp @@ -128,4 +128,4 @@ int main() } return 0; -} \ No newline at end of file +} From 6293da4379647aba8434bcd05c267dc4b1cfdcdd Mon Sep 17 00:00:00 2001 From: Rabhinav2003 <116386391+Rabhinav2003@users.noreply.github.com> Date: Sat, 22 Oct 2022 01:54:53 +0530 Subject: [PATCH 27/27] Create tictactoe.cpp --- c++/tictactoe.cpp | 125 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 c++/tictactoe.cpp diff --git a/c++/tictactoe.cpp b/c++/tictactoe.cpp new file mode 100644 index 0000000..16b7b72 --- /dev/null +++ b/c++/tictactoe.cpp @@ -0,0 +1,125 @@ +//Tic Tac Toe Game in C++ + +//Importing the inbuild libraries in CPP +#include +#include +using namespace std; +//Array for the board +char board[3][3] = {{'1','2','3'},{'4','5','6'},{'7','8','9'}}; +//Variable Declaration +int choice; +int row,column; +char turn = 'X'; +bool draw = false; + +//Function to show the current status of the gaming board + +void display_board(){ + + //Rander Game Board LAYOUT + + cout<<"PLAYER - 1 [X]t PLAYER - 2 [O]nn"; + cout<<"tt | | n"; + cout<<"tt "<> choice; + + //switch case to get which row and column will be update + + switch(choice){ + case 1: row=0; column=0; break; + case 2: row=0; column=1; break; + case 3: row=0; column=2; break; + case 4: row=1; column=0; break; + case 5: row=1; column=1; break; + case 6: row=1; column=2; break; + case 7: row=2; column=0; break; + case 8: row=2; column=1; break; + case 9: row=2; column=2; break; + default: + cout<<"Invalid Move"; + } + + if(turn == 'X' && board[row][column] != 'X' && board[row][column] != 'O'){ + //updating the position for 'X' symbol if + //it is not already occupied + board[row][column] = 'X'; + turn = 'O'; + }else if(turn == 'O' && board[row][column] != 'X' && board[row][column] != 'O'){ + //updating the position for 'O' symbol if + //it is not already occupied + board[row][column] = 'O'; + turn = 'X'; + }else { + //if input position already filled + cout<<"Box already filled!n Please choose another!!nn"; + player_turn(); + } + /* Ends */ + display_board(); +} + +//Function to get the game status e.g. GAME WON, GAME DRAW GAME IN CONTINUE MODE + +bool gameover(){ + //checking the win for Simple Rows and Simple Column + for(int i=0; i<3; i++) + if(board[i][0] == board[i][1] && board[i][0] == board[i][2] || board[0][i] == board[1][i] && board[0][i] == board[2][i]) + return false; + + //checking the win for both diagonal + + if(board[0][0] == board[1][1] && board[0][0] == board[2][2] || board[0][2] == board[1][1] && board[0][2] == board[2][0]) + return false; + + //Checking the game is in continue mode or not + for(int i=0; i<3; i++) + for(int j=0; j<3; j++) + if(board[i][j] != 'X' && board[i][j] != 'O') + return true; + + //Checking the if game already draw + draw = true; + return false; +} + +//Program Main Method + +int main() +{ + cout<<"tttT I C K -- T A C -- T O E -- G A M Ettt"; + cout<<"nttttFOR 2 PLAYERSnttt"; + while(gameover()){ + display_board(); + player_turn(); + gameover(); + } + if(turn == 'X' && draw == false){ + cout<<"nnCongratulations!Player with 'X' has won the game"; + } + else if(turn == 'O' && draw == false){ + cout<<"nnCongratulations!Player with 'O' has won the game"; + } + else + cout<<"nnGAME DRAW!!!nn"; +}