mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-03 18:46:50 +08:00
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 fora01765a6* Restored original settings * clang-format and clang-tidy fixes for6a8f3a4eCo-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: David Leal <halfpacho@gmail.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user