题目要求:
规定这样一种形状的三角形,如图7-36所示为一个符号三角形:
#include "stdio.h"typedef struct QNode{/*定义队列结点类*/char data;struct QNode *next;} QNode , *QueuePtr;typedef struct{/*定义一个链队列*/QueuePtr front;/*队头指针*/QueuePtr rear;/*队尾指针*/}LinkQueue;initQueue(LinkQueue *q){/*初始化一个空队列*/q->front = q->rear = (QueuePtr)malloc(sizeof(QNode));/*创建一个头结点,队头队尾指针指向该结点*/if( !q->front) exit(0);/*创建头结点失败*/q->front->next = NULL;/*头结点指针域置NULL*/}EnQueue(LinkQueue *q, char e){/*入队列操作*/QueuePtr p;p = (QueuePtr)malloc(sizeof(QNode)); /*创建一个队列元素结点*/if( !q->front) exit(0);/*创建头结点失败*/p->data = https://www.bjxdyg.com/life/e;/*将元素e入队列*/p->next = NULL;/*修改队尾指针*/q->rear ->next = p;q->rear = p;}DeQueue(LinkQueue *q, char *e){/*如果队列q不为空,删除q的队头元素,用e返回其值*/QueuePtr p;if(q->front == q->rear) return;/*队列为空 , 返回*/p = q->front->next;*e = p->data;q->front->next = p->next;if(q->rear == p) q->rear = q->front;/*如果队头就是队尾,则修改队尾指针*/free(p);}printTriangle(int n){LinkQueue q;char e,a,b ;int i,j;initQueue(&q);/*初始化队列*/printf("Input the the charecter(+/-) of the row.1n");for(i=0;i运行结果:
【word文档三角形符号怎么打 三角形符号怎么打】运行结果
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- word里清除内容 word文档怎么清除内容
- word字体怎么无限加粗 word字体怎么无限加粗加大
- word怎么添加字体 word怎么添加字体样式
- Word如何为页面添加背景
- 手机里怎么编辑word文档电子版 手机里怎么编辑word文档
- 文档字体大小怎么调整 电脑文档字体大小怎么调
- word方框中打√符号教程 打钩符号怎么打出来框怎么点击就打上
- word未经授权产品什么意思 word未经授权产品怎么激活
- 上下边距怎么设置 word上下边距怎么设置
- WPS文档如何清除格式 wps文档如何清除格式内容