PTA
openallzzz
计算机交流群:743998243,2023CCPC河北省大学生程序设计竞赛银牌、2022CCPC河北省大学生程序设计竞赛铜牌、第十四届蓝桥杯C++B组河北省赛一等奖(22名)、第十四届蓝桥杯C++B组决赛国家二等奖、邮箱:zythrough@gmail.com
展开
-
PTA - 6-1 输出二叉树的所有叶子 (15 分)
void leaf(Bptr p){ if(!p){ return; } leaf(p->Lson); if(!(p->Lson) && !(p->Rson)){ printf("%d ", p->data); return; } leaf(p->Rson);}原创 2021-11-28 15:37:22 · 1282 阅读 · 7 评论 -
PTA - 6-3 十进制转二进制(顺序栈设计和应用) (10 分)
// #define MaxSize 100 /* 栈最大容量 */// int top; /* 栈顶指针 */// int mystack[MaxSize]; /* 顺序栈 *//*判栈是否为空,空返回true,非空返回false */bool isEmpty(){ if(top == -1) return true; return false;}/* 元素x入栈 */void Push(int x){ if(top < MaxSi原创 2021-11-28 15:31:52 · 1968 阅读 · 0 评论 -
PTA - 6-2 循环队列入队出队 (70 分)
// squeue是循环队列的地址void EnQueue_seq(SeqQueue squeue, DataType x){ if((squeue->r + 1) % squeue->Max == squeue->f){ printf("It is FULL Queue!"); }else{ squeue->elem[squeue->r] = x; squeue->r = (squeue->r +原创 2021-11-28 15:30:40 · 4033 阅读 · 4 评论 -
PTA - 6-1 带头结点的链队列的基本操作 (10 分)
Status QueueInsert(LinkQueue *Q,ElemType e){ LNode* insertNode = (LNode*)malloc(sizeof(LNode)); if(insertNode == NULL) return ERROR; insertNode->data = e; insertNode->next = NULL; Q->rear->next = insertNode; Q-原创 2021-11-28 15:29:16 · 907 阅读 · 0 评论