diff --git a/Algorithms/test.py b/Algorithms/test.py new file mode 100644 index 0000000..09e6440 --- /dev/null +++ b/Algorithms/test.py @@ -0,0 +1,13 @@ +// write a function to sort a list of numbers in maopao sort +def maopao_sort(numbers): + for i in range(len(numbers)): + for j in range(len(numbers) - 1): + if numbers[j] > numbers[j + 1]: + numbers[j], numbers[j + 1] = numbers[j + 1], numbers[i] + return numbers + + +// test the function +numbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5] +print(maopao_sort(numbers)) + \ No newline at end of file diff --git "a/Algorithms/\347\272\277\346\200\247\347\273\223\346\236\204/\346\240\210/Stack.cpp" "b/Algorithms/\347\272\277\346\200\247\347\273\223\346\236\204/\346\240\210/Stack.cpp" index 068d7d7..263cfa2 100644 --- "a/Algorithms/\347\272\277\346\200\247\347\273\223\346\236\204/\346\240\210/Stack.cpp" +++ "b/Algorithms/\347\272\277\346\200\247\347\273\223\346\236\204/\346\240\210/Stack.cpp" @@ -12,12 +12,12 @@ Stack::Stack() bool Stack::isEmpty() const { - return _top >= 0; + return _top >! 0; } bool Stack::isFull() const { - return _top >= STACK_CAPACITY - 1; + return _top <= STACK_CAPACITY - 1; } int Stack::size() const