diff --git a/.github/workflows/awesome_forkflow.yml b/.github/workflows/awesome_forkflow.yml index 05094bdd1..93b630d05 100644 --- a/.github/workflows/awesome_forkflow.yml +++ b/.github/workflows/awesome_forkflow.yml @@ -167,13 +167,13 @@ jobs: print("cpplint:") for cpp_file in cpp_files: - subprocess.run(["cpplint", "--filter=-legal/copyright", cpp_file], check=True, text=True) + subprocess.run(["cpplint", "--filter=-legal/copyright,-build/include", cpp_file], check=True, text=True) - print("g++:") + # print("g++:") # compile_exts = tuple(".c .c++ .cc .cpp .cu .cxx".split()) # compile_files = [file for file in cpp_files if file.lower().endswith(compile_exts)] - for cpp_file in cpp_files: - subprocess.run(["g++", cpp_file], check=True, text=True) + # for cpp_file in cpp_files: + # subprocess.run(["g++", cpp_file], check=True, text=True) upper_files = [file for file in cpp_files if file != file.lower()] if upper_files: diff --git a/CMakeLists.txt b/CMakeLists.txt index 25e8dc4a4..957be35f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,6 @@ if(DOXYGEN_FOUND) set(DOXYGEN_INLINE_SOURCES YES) set(DOXYGEN_CREATE_SUBDIRS YES) set(DOXYGEN_EXTRACT_PRIVATE YES) - set(DOCYGEN_GENERATE_TREEVIEW YES) set(DOXYGEN_GENERATE_TREEVIEW YES) set(DOXYGEN_STRIP_CODE_COMMENTS NO) set(DOXYGEN_EXT_LINKS_IN_WINDOW YES) diff --git a/DIRECTORY.md b/DIRECTORY.md index bdfa2c951..31093341a 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -25,21 +25,17 @@ * [Linkedlist Implentation Usingarray](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/linkedlist_implentation_usingarray.cpp) * [List Array](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/list_array.cpp) * [Morrisinorder](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/morrisinorder.cpp) - * Queue - * [Queue](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/queue/queue.cpp) - * [Queue](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/queue/queue.h) - * [Test Queue](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/queue/test_queue.cpp) + * [Queue](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/queue.h) * [Queue Using Array](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/queue_using_array.cpp) * [Queue Using Array2](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/queue_using_array2.cpp) * [Queue Using Linked List](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/queue_using_linked_list.cpp) * [Queue Using Linkedlist](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/queue_using_linkedlist.cpp) + * [Stack](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/stack.h) * [Stack Using Array](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/stack_using_array.cpp) * [Stack Using Linked List](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/stack_using_linked_list.cpp) - * Stk - * [Main](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/stk/main.cpp) - * [Stack](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/stk/stack.cpp) - * [Stack](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/stk/stack.h) - * [Test Stack](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/stk/test_stack.cpp) + * [Test Queue](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/test_queue.cpp) + * [Test Stack](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/test_stack.cpp) + * [Test Stack Students](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/test_stack_students.cpp) * [Tree](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/tree.cpp) * [Trie Modern](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/trie_modern.cpp) * [Trie Tree](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/data_structures/trie_tree.cpp) diff --git a/data_structures/CMakeLists.txt b/data_structures/CMakeLists.txt index 7840c8349..6c0555148 100644 --- a/data_structures/CMakeLists.txt +++ b/data_structures/CMakeLists.txt @@ -16,3 +16,5 @@ foreach( testsourcefile ${APP_SOURCES} ) install(TARGETS ${testname} DESTINATION "bin/data_structures") endforeach( testsourcefile ${APP_SOURCES} ) + +add_subdirectory(cll) diff --git a/data_structures/cll/CMakeLists.txt b/data_structures/cll/CMakeLists.txt new file mode 100644 index 000000000..cb18eb347 --- /dev/null +++ b/data_structures/cll/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable( cll + cll.cpp + main_cll.cpp +) +install(TARGETS cll DESTINATION "bin/data_structures") diff --git a/data_structures/cll/makefile b/data_structures/cll/makefile deleted file mode 100644 index 0f8734eab..000000000 --- a/data_structures/cll/makefile +++ /dev/null @@ -1,11 +0,0 @@ -CC= g++ -CFLAGS = -c -Wall - -all: cll -cll.o: cll.cpp main_cll.cpp - $(CC) $(CFLAGS) cll.cpp main_cll.cpp -cll: cll.o - $(CC) main_cll.o cll.o -o cll - -clean: - rm *o cll diff --git a/data_structures/queue.h b/data_structures/queue.h new file mode 100644 index 000000000..3cb551741 --- /dev/null +++ b/data_structures/queue.h @@ -0,0 +1,88 @@ +/* This class specifies the basic operation on a queue as a linked list */ +#ifndef DATA_STRUCTURES_QUEUE_H_ +#define DATA_STRUCTURES_QUEUE_H_ + +#include +#include + +/** Definition of the node */ +template +struct node { + Kind data; + node *next; +}; + +/** Definition of the queue class */ +template +class queue { + public: + /** Show queue */ + void display() { + node *current = queueFront; + std::cout << "Front --> "; + while (current != NULL) { + std::cout << current->data << " "; + current = current->next; + } + std::cout << std::endl; + std::cout << "Size of queue: " << size << std::endl; + } + + /** Default constructor*/ + queue() { + queueFront = NULL; + queueRear = NULL; + size = 0; + } + + /** Destructor */ + ~queue() {} + + /** Determine whether the queue is empty */ + bool isEmptyQueue() { return (queueFront == NULL); } + + /** Add new item to the queue */ + void enQueue(Kind item) { + node *newNode; + newNode = new node; + newNode->data = item; + newNode->next = NULL; + if (queueFront == NULL) { + queueFront = newNode; + queueRear = newNode; + } else { + queueRear->next = newNode; + queueRear = queueRear->next; + } + size++; + } + + /** Return the first element of the queue */ + Kind front() { + assert(queueFront != NULL); + return queueFront->data; + } + + /** Remove the top element of the queue */ + void deQueue() { + node *temp; + if (!isEmptyQueue()) { + temp = queueFront; + queueFront = queueFront->next; + delete temp; + size--; + } else { + std::cout << "Queue is empty !" << std::endl; + } + } + + /** Clear queue */ + void clear() { queueFront = NULL; } + + private: + node *queueFront; /**< Pointer to the front of the queue */ + node *queueRear; /**< Pointer to the rear of the queue */ + int size; +}; + +#endif // DATA_STRUCTURES_QUEUE_H_ diff --git a/data_structures/queue/makefile b/data_structures/queue/makefile deleted file mode 100644 index 420909804..000000000 --- a/data_structures/queue/makefile +++ /dev/null @@ -1,11 +0,0 @@ -CC= g++ -CFLAGS = -c -Wall - -all: test_queue -queue.o: queue.cpp - $(CC) $(CFLAGS) queue.cpp -test_queue: queue.o - $(CC) test_queue.cpp queue.o -o queue - -clean: - rm *o queue diff --git a/data_structures/queue/queue.cpp b/data_structures/queue/queue.cpp deleted file mode 100644 index a7055bb14..000000000 --- a/data_structures/queue/queue.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include "queue.h" -#include -#include - -using namespace std; - -/* Default constructor*/ -template -queue::queue() { - queueFront = NULL; - queueRear = NULL; - size = 0; -} - -/* Destructor */ -template -queue::~queue() {} - -/* Display for testing */ -template -void queue::display() { - node *current = queueFront; - cout << "Front --> "; - while (current != NULL) { - cout << current->data << " "; - current = current->next; - } - cout << endl; - cout << "Size of queue: " << size << endl; -} - -/* Determine whether the queue is empty */ -template -bool queue::isEmptyQueue() { - return (queueFront == NULL); -} - -/* Clear queue */ -template -void queue::clear() { - queueFront = NULL; -} - -/* Add new item to the queue */ -template -void queue::enQueue(Kind item) { - node *newNode; - newNode = new node; - newNode->data = item; - newNode->next = NULL; - if (queueFront == NULL) { - queueFront = newNode; - queueRear = newNode; - } else { - queueRear->next = newNode; - queueRear = queueRear->next; - } - size++; -} - -/* Return the top element of the queue */ -template -Kind queue::front() { - assert(queueFront != NULL); - return queueFront->data; -} - -/* Remove the element of the queue */ -template -void queue::deQueue() { - node *temp; - if (!isEmptyQueue()) { - temp = queueFront; - queueFront = queueFront->next; - delete temp; - size--; - } else { - cout << "Queue is empty !" << endl; - } -} diff --git a/data_structures/queue/queue.h b/data_structures/queue/queue.h deleted file mode 100644 index d1305fc81..000000000 --- a/data_structures/queue/queue.h +++ /dev/null @@ -1,31 +0,0 @@ -/* This class specifies the basic operation on a queue as a linked list */ -#ifndef QUEUE_H -#define QUEUE_H - -/* Definition of the node */ -template -struct node { - Kind data; - node *next; -}; - -/* Definition of the queue class */ -template -class queue { - public: - void display(); /* Show queue */ - queue(); /* Default constructor*/ - ~queue(); /* Destructor */ - bool isEmptyQueue(); /* Determine whether the queue is empty */ - void enQueue(Kind item); /* Add new item to the queue */ - Kind front(); /* Return the first element of the queue */ - void deQueue(); /* Remove the top element of the queue */ - void clear(); - - private: - node *queueFront; /* Pointer to the front of the queue */ - node *queueRear; /* Pointer to the rear of the queue */ - int size; -}; - -#endif diff --git a/data_structures/queue/test_queue.cpp b/data_structures/queue/test_queue.cpp deleted file mode 100644 index 7f0923f78..000000000 --- a/data_structures/queue/test_queue.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include -#include "queue.cpp" -#include "queue.h" - -using namespace std; - -int main() { - queue q; - cout << "---------------------- Test construct ----------------------" - << endl; - q.display(); - cout << "---------------------- Test isEmptyQueue ----------------------" - << endl; - if (q.isEmptyQueue()) - cout << "PASS" << endl; - else - cout << "FAIL" << endl; - cout << "---------------------- Test enQueue ----------------------" - << endl; - cout << "After Hai, Jeff, Tom, Jkingston go into queue: " << endl; - q.enQueue("Hai"); - q.enQueue("Jeff"); - q.enQueue("Tom"); - q.enQueue("Jkingston"); - q.display(); - cout << "---------------------- Test front ----------------------" << endl; - string value = q.front(); - if (value == "Hai") - cout << "PASS" << endl; - else - cout << "FAIL" << endl; - cout << "---------------------- Test deQueue ----------------------" - << endl; - q.display(); - q.deQueue(); - q.deQueue(); - cout << "After Hai, Jeff left the queue: " << endl; - q.display(); - return 0; -} diff --git a/data_structures/stack.h b/data_structures/stack.h new file mode 100644 index 000000000..f4b8992e7 --- /dev/null +++ b/data_structures/stack.h @@ -0,0 +1,111 @@ +/* This class specifies the basic operation on a stack as a linked list */ +#ifndef DATA_STRUCTURES_STACK_H_ +#define DATA_STRUCTURES_STACK_H_ + +#include +#include + +/* Definition of the node */ +template +struct node { + Type data; + node *next; +}; + +/* Definition of the stack class */ +template +class stack { + public: + /** Show stack */ + void display() { + node *current = stackTop; + std::cout << "Top --> "; + while (current != NULL) { + std::cout << current->data << " "; + current = current->next; + } + std::cout << std::endl; + std::cout << "Size of stack: " << size << std::endl; + } + + /** Default constructor*/ + stack() { + stackTop = NULL; + size = 0; + } + + /** Destructor */ + ~stack() {} + + /** Determine whether the stack is empty */ + bool isEmptyStack() { return (stackTop == NULL); } + + /** Add new item to the stack */ + void push(Type item) { + node *newNode; + newNode = new node; + newNode->data = item; + newNode->next = stackTop; + stackTop = newNode; + size++; + } + + /** Return the top element of the stack */ + Type top() { + assert(stackTop != NULL); + return stackTop->data; + } + + /** Remove the top element of the stack */ + void pop() { + node *temp; + if (!isEmptyStack()) { + temp = stackTop; + stackTop = stackTop->next; + delete temp; + size--; + } else { + std::cout << "Stack is empty !" << std::endl; + } + } + + /** Clear stack */ + void clear() { stackTop = NULL; } + + /** Overload "=" the assignment operator */ + stack &operator=(const stack &otherStack) { + node *newNode, *current, *last; + + /* If stack is no empty, make it empty */ + if (stackTop != NULL) { + stackTop = NULL; + } + if (otherStack.stackTop == NULL) { + stackTop = NULL; + } else { + current = otherStack.stackTop; + stackTop = new node; + stackTop->data = current->data; + stackTop->next = NULL; + last = stackTop; + current = current->next; + /* Copy the remaining stack */ + while (current != NULL) { + newNode = new node; + newNode->data = current->data; + newNode->next = NULL; + last->next = newNode; + last = newNode; + current = current->next; + } + } + size = otherStack.size; + return *this; + } + + private: + node *stackTop; /**< Pointer to the stack */ + int size; +}; + +#endif // DATA_STRUCTURES_STACK_H_ diff --git a/data_structures/stk/makefile b/data_structures/stk/makefile deleted file mode 100644 index e965d2044..000000000 --- a/data_structures/stk/makefile +++ /dev/null @@ -1,13 +0,0 @@ -CC= g++ -CFLAGS = -c -Wall - -all: main test_stack -stack.o: stack.cpp - $(CC) $(CFLAGS) stack.cpp -test_stack: stack.o - $(CC) test_stack.cpp stack.o -o stk -main: stack.o - $(CC) main.cpp stack.o -o main - -clean: - rm *o stk main diff --git a/data_structures/stk/stack.cpp b/data_structures/stk/stack.cpp deleted file mode 100644 index bfa8a353e..000000000 --- a/data_structures/stk/stack.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "stack.h" -#include -#include - -using namespace std; - -/* Default constructor*/ -template -stack::stack() { - stackTop = NULL; - size = 0; -} - -/* Destructor */ -template -stack::~stack() {} - -/* Display for testing */ -template -void stack::display() { - node *current = stackTop; - cout << "Top --> "; - while (current != NULL) { - cout << current->data << " "; - current = current->next; - } - cout << endl; - cout << "Size of stack: " << size << endl; -} - -/* Determine whether the stack is empty */ -template -bool stack::isEmptyStack() { - return (stackTop == NULL); -} - -/* Clear stack */ -template -void stack::clear() { - stackTop = NULL; -} - -/* Add new item to the stack */ -template -void stack::push(Type item) { - node *newNode; - newNode = new node; - newNode->data = item; - newNode->next = stackTop; - stackTop = newNode; - size++; -} - -/* Return the top element of the stack */ -template -Type stack::top() { - assert(stackTop != NULL); - return stackTop->data; -} - -/* Remove the top element of the stack */ -template -void stack::pop() { - node *temp; - if (!isEmptyStack()) { - temp = stackTop; - stackTop = stackTop->next; - delete temp; - size--; - } else { - cout << "Stack is empty !" << endl; - } -} - -/* Operator "=" */ -template -stack stack::operator=(stack &otherStack) { - node *newNode, *current, *last; - - if (stackTop != NULL) /* If stack is no empty, make it empty */ - stackTop = NULL; - if (otherStack.stackTop == NULL) - stackTop = NULL; - else { - current = otherStack.stackTop; - stackTop = new node; - stackTop->data = current->data; - stackTop->next = NULL; - last = stackTop; - current = current->next; - /* Copy the remaining stack */ - while (current != NULL) { - newNode = new node; - newNode->data = current->data; - newNode->next = NULL; - last->next = newNode; - last = newNode; - current = current->next; - } - } - size = otherStack.size; - return *this; -} diff --git a/data_structures/stk/stack.h b/data_structures/stk/stack.h deleted file mode 100644 index da7788b73..000000000 --- a/data_structures/stk/stack.h +++ /dev/null @@ -1,32 +0,0 @@ -/* This class specifies the basic operation on a stack as a linked list */ -#ifndef STACK_H -#define STACK_H - -/* Definition of the node */ -template -struct node { - Type data; - node *next; -}; - -/* Definition of the stack class */ -template -class stack { - public: - void display(); /* Show stack */ - stack(); /* Default constructor*/ - ~stack(); /* Destructor */ - bool isEmptyStack(); /* Determine whether the stack is empty */ - void push(Type item); /* Add new item to the stack */ - Type top(); /* Return the top element of the stack */ - void pop(); /* Remove the top element of the stack */ - void clear(); - - stack operator=(stack &otherStack); - // Overload "=" the assignment operator. - private: - node *stackTop; /* Pointer to the stack */ - int size; -}; - -#endif diff --git a/data_structures/stk/test_stack.cpp b/data_structures/stk/test_stack.cpp deleted file mode 100644 index 098027dfd..000000000 --- a/data_structures/stk/test_stack.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include "stack.cpp" -#include "stack.h" - -using namespace std; - -int main() { - stack stk; - cout << "---------------------- Test construct ----------------------" - << endl; - stk.display(); - cout << "---------------------- Test isEmptyStack ----------------------" - << endl; - if (stk.isEmptyStack()) - cout << "PASS" << endl; - else - cout << "FAIL" << endl; - cout << "---------------------- Test push ----------------------" << endl; - cout << "After pushing 10 20 30 40 into stack: " << endl; - stk.push(10); - stk.push(20); - stk.push(30); - stk.push(40); - stk.display(); - cout << "---------------------- Test top ----------------------" << endl; - int value = stk.top(); - if (value == 40) - cout << "PASS" << endl; - else - cout << "FAIL" << endl; - cout << "---------------------- Test pop ----------------------" << endl; - stk.display(); - stk.pop(); - stk.pop(); - cout << "After popping 2 times: " << endl; - stk.display(); - cout << "---------------------- Test overload = operator " - "----------------------" - << endl; - stack stk1; - cout << "stk current: " << endl; - stk.display(); - cout << endl << "Assign stk1 = stk " << endl; - stk1 = stk; - stk1.display(); - cout << endl << "After pushing 8 9 10 into stk1:" << endl; - stk1.push(8); - stk1.push(9); - stk1.push(10); - stk1.display(); - cout << endl << "stk current: " << endl; - stk.display(); - cout << "Assign back stk = stk1:" << endl; - stk = stk1; - stk.display(); - return 0; -} diff --git a/data_structures/stk/student.txt b/data_structures/student.txt similarity index 100% rename from data_structures/stk/student.txt rename to data_structures/student.txt diff --git a/data_structures/test_queue.cpp b/data_structures/test_queue.cpp new file mode 100644 index 000000000..387ccf2f7 --- /dev/null +++ b/data_structures/test_queue.cpp @@ -0,0 +1,41 @@ +#include +#include + +#include "./queue.h" + +int main() { + queue q; + std::cout << "---------------------- Test construct ----------------------" + << std::endl; + q.display(); + std::cout + << "---------------------- Test isEmptyQueue ----------------------" + << std::endl; + if (q.isEmptyQueue()) + std::cout << "PASS" << std::endl; + else + std::cout << "FAIL" << std::endl; + std::cout << "---------------------- Test enQueue ----------------------" + << std::endl; + std::cout << "After Hai, Jeff, Tom, Jkingston go into queue: " << std::endl; + q.enQueue("Hai"); + q.enQueue("Jeff"); + q.enQueue("Tom"); + q.enQueue("Jkingston"); + q.display(); + std::cout << "---------------------- Test front ----------------------" + << std::endl; + std::string value = q.front(); + if (value == "Hai") + std::cout << "PASS" << std::endl; + else + std::cout << "FAIL" << std::endl; + std::cout << "---------------------- Test deQueue ----------------------" + << std::endl; + q.display(); + q.deQueue(); + q.deQueue(); + std::cout << "After Hai, Jeff left the queue: " << std::endl; + q.display(); + return 0; +} diff --git a/data_structures/test_stack.cpp b/data_structures/test_stack.cpp new file mode 100644 index 000000000..aa636916f --- /dev/null +++ b/data_structures/test_stack.cpp @@ -0,0 +1,59 @@ +#include + +#include "./stack.h" + +int main() { + stack stk; + std::cout << "---------------------- Test construct ----------------------" + << std::endl; + stk.display(); + std::cout + << "---------------------- Test isEmptyStack ----------------------" + << std::endl; + if (stk.isEmptyStack()) + std::cout << "PASS" << std::endl; + else + std::cout << "FAIL" << std::endl; + std::cout << "---------------------- Test push ----------------------" + << std::endl; + std::cout << "After pushing 10 20 30 40 into stack: " << std::endl; + stk.push(10); + stk.push(20); + stk.push(30); + stk.push(40); + stk.display(); + std::cout << "---------------------- Test top ----------------------" + << std::endl; + int value = stk.top(); + if (value == 40) + std::cout << "PASS" << std::endl; + else + std::cout << "FAIL" << std::endl; + std::cout << "---------------------- Test pop ----------------------" + << std::endl; + stk.display(); + stk.pop(); + stk.pop(); + std::cout << "After popping 2 times: " << std::endl; + stk.display(); + std::cout << "---------------------- Test overload = operator " + "----------------------" + << std::endl; + stack stk1; + std::cout << "stk current: " << std::endl; + stk.display(); + std::cout << std::endl << "Assign stk1 = stk " << std::endl; + stk1 = stk; + stk1.display(); + std::cout << std::endl << "After pushing 8 9 10 into stk1:" << std::endl; + stk1.push(8); + stk1.push(9); + stk1.push(10); + stk1.display(); + std::cout << std::endl << "stk current: " << std::endl; + stk.display(); + std::cout << "Assign back stk = stk1:" << std::endl; + stk = stk1; + stk.display(); + return 0; +} diff --git a/data_structures/stk/main.cpp b/data_structures/test_stack_students.cpp similarity index 70% rename from data_structures/stk/main.cpp rename to data_structures/test_stack_students.cpp index 44b7984e0..a6048c4c9 100644 --- a/data_structures/stk/main.cpp +++ b/data_structures/test_stack_students.cpp @@ -8,29 +8,26 @@ * ./main student.txt ************************************************************ * */ -#include +#include #include #include #include #include -#include "stack.cpp" -#include "stack.h" - -using namespace std; +#include "./stack.h" int main(int argc, char* argv[]) { double GPA; double highestGPA; - string name; + std::string name; assert(argc == 2); - ifstream infile; - stack stk; + std::ifstream infile; + stack stk; infile.open(argv[1]); - cout << fixed << showpoint; - cout << setprecision(2); + std::cout << std::fixed << std::showpoint; + std::cout << std::setprecision(2); infile >> GPA >> name; highestGPA = GPA; @@ -44,12 +41,12 @@ int main(int argc, char* argv[]) { } infile >> GPA >> name; } - cout << "Highest GPA: " << highestGPA << endl; - cout << "Students the highest GPA are: " << endl; + std::cout << "Highest GPA: " << highestGPA << std::endl; + std::cout << "Students the highest GPA are: " << std::endl; while (!stk.isEmptyStack()) { - cout << stk.top() << endl; + std::cout << stk.top() << std::endl; stk.pop(); } - cout << endl; + std::cout << std::endl; return 0; }