diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0e7e966 --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +# Ignore build and output directories +bin/ +out/ +build/ +target/ +release/ +dist/ +.idea/ +.vscode/ +*.suo +*.user +*.sdf + +# Ignore compiler-generated files +*.o +*.out +*.class +*.jar +*.exe +*.dll + +# Ignore text editor/IDE-specific files +*.swo +*.swp +*.swn +*.suo +*.user +*.log +*.orig + +# Ignore OS-generated files +.DS_Store +Thumbs.db diff --git a/C++/RadixSort.exe b/C++/RadixSort.exe deleted file mode 100644 index 38dc12f..0000000 Binary files a/C++/RadixSort.exe and /dev/null differ diff --git a/C++/StackUsingQueue.cpp b/C++/StackUsingQueue.cpp new file mode 100644 index 0000000..6b6d6a3 --- /dev/null +++ b/C++/StackUsingQueue.cpp @@ -0,0 +1,58 @@ +#include +#include + +using namespace std; + +class StackUsingQueues { +public: + void push(int x) { + tempQueue.push(x); + while (!mainQueue.empty()) { + tempQueue.push(mainQueue.front()); + mainQueue.pop(); + } + + // Swap the main and temporary queues (main = temp, temp = empty) + mainQueue.swap(tempQueue); + } + + void pop() { + mainQueue.pop(); + } + + int top() { + return mainQueue.front(); + } + + bool empty() { + return mainQueue.empty(); + } + +private: + queue mainQueue; + queue tempQueue; +}; + +int main() { + + StackUsingQueues stack; + + stack.push(1); + stack.push(2); + stack.push(3); + stack.push(4); + stack.push(5); + + cout << "Top element: " << stack.top() << endl; // Output: 5 + + stack.pop(); + + cout << "Top element after pop: " << stack.top() << endl; // Output: 4 + + stack.push(6); + + cout << "Top element: " << stack.top() << endl; // Output: 6 + + system("pause"); + return 0; +} diff --git a/C++/TowerofHanoi b/C++/TowerofHanoi deleted file mode 100755 index fda0062..0000000 Binary files a/C++/TowerofHanoi and /dev/null differ diff --git a/C++/bubbleSort.exe b/C++/bubbleSort.exe deleted file mode 100644 index 621eb31..0000000 Binary files a/C++/bubbleSort.exe and /dev/null differ diff --git a/C++/circularQueue b/C++/circularQueue deleted file mode 100755 index 6a8b36e..0000000 Binary files a/C++/circularQueue and /dev/null differ diff --git a/C++/reverseLinkedList b/C++/reverseLinkedList deleted file mode 100755 index cc26231..0000000 Binary files a/C++/reverseLinkedList and /dev/null differ diff --git a/C++/stackOperations b/C++/stackOperations deleted file mode 100755 index 0853ed9..0000000 Binary files a/C++/stackOperations and /dev/null differ