feat: Modify search/text_search.cpp (#1662)

* Modified search/text_search.cpp

* Added tests

* Added a few test cases

* Added a few more test cases and documentation

* Minor fix

* Minor fixes

* Minor fixes

* Minor output fixes

* Minor output fixes

* Minor readability fixes

* clang-format and clang-tidy fixes for a01765a6

* Restored original settings

* clang-format and clang-tidy fixes for 6a8f3a4e

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
This commit is contained in:
Anuran Roy
2021-10-15 00:04:55 +05:30
committed by GitHub
parent 5a654fb85b
commit 85721be69b
5 changed files with 217 additions and 123 deletions

View File

@@ -15,7 +15,7 @@ void push(int x) {
}
void pop() {
if (top_var == NULL) {
if (top_var == nullptr) {
std::cout << "\nUnderflow";
} else {
node *t = top_var;
@@ -27,14 +27,14 @@ void pop() {
void show() {
node *t = top_var;
while (t != NULL) {
while (t != nullptr) {
std::cout << t->val << "\n";
t = t->next;
}
}
int main() {
int ch, x;
int ch = 0, x = 0;
do {
std::cout << "\n0. Exit or Ctrl+C";
std::cout << "\n1. Push";
@@ -42,17 +42,23 @@ int main() {
std::cout << "\n3. Print";
std::cout << "\nEnter Your Choice: ";
std::cin >> ch;
switch(ch){
case 0: break;
case 1: std::cout << "\nInsert : ";
switch (ch) {
case 0:
break;
case 1:
std::cout << "\nInsert : ";
std::cin >> x;
push(x);
break;
case 2: pop();
case 2:
pop();
break;
case 3: show();
case 3:
show();
break;
default:
std::cout << "Invalid option!\n";
break;
default: std::cout << "Invalid option!\n"; break;
}
} while (ch != 0);