Format C++ codes in Clang-Format Style: Microsoft

This commit is contained in:
krahets
2023-04-14 03:44:02 +08:00
parent f8513455b5
commit 9c9c8b7574
46 changed files with 732 additions and 888 deletions

View File

@ -8,10 +8,10 @@
/* 基于数组实现的栈 */
class ArrayStack {
private:
private:
vector<int> stack;
public:
public:
/* 获取栈的长度 */
int size() {
return stack.size();
@ -35,7 +35,7 @@ public:
/* 访问栈顶元素 */
int top() {
if(empty())
if (empty())
throw out_of_range("栈为空");
return stack.back();
}
@ -46,11 +46,10 @@ public:
}
};
/* Driver Code */
int main() {
/* 初始化栈 */
ArrayStack* stack = new ArrayStack();
ArrayStack *stack = new ArrayStack();
/* 元素入栈 */
stack->push(1);
@ -59,7 +58,7 @@ int main() {
stack->push(5);
stack->push(4);
cout << "栈 stack = ";
PrintUtil::printVector(stack->toVector());
printVector(stack->toVector());
/* 访问栈顶元素 */
int top = stack->top();
@ -68,7 +67,7 @@ int main() {
/* 元素出栈 */
stack->pop();
cout << "出栈元素 pop = " << top << ",出栈后 stack = ";
PrintUtil::printVector(stack->toVector());
printVector(stack->toVector());
/* 获取栈的长度 */
int size = stack->size();