当前位置: 首页 > news >正文

怎么制作网站模版百度推广销售

怎么制作网站模版,百度推广销售,太原广告传媒有限公司,网站建设行业毕业论文1.队列元素逆置 【问题描述】 已知Q是一个非空队列,S是一个空栈。仅使用少量工作变量以及对队列和栈的基本操作,编写一个算法,将队列Q中的所有元素逆置。 【输入形式】 输入的第一行为队列元素个数,第二行为队列从首至尾的元素…

1.队列元素逆置

【问题描述】

已知Q是一个非空队列,S是一个空栈。仅使用少量工作变量以及对队列和栈的基本操作,编写一个算法,将队列Q中的所有元素逆置。

【输入形式】

输入的第一行为队列元素个数,第二行为队列从首至尾的元素

【输出形式】

输出队列的逆置

【样例输入】

3
1 2 3

【样例输出】

3 2 1

【评分标准】

需采用队列与栈的知识,否则不能得分

C语言

#include <stdio.h>
#include <stdlib.h>#define MAX_SIZE 3000typedef struct {int data[MAX_SIZE];int front;int rear;
} Queue;void initQueue(Queue *q) {q->front = 0;q->rear = -1;
}int isEmpty(Queue *q) {return q->front > q->rear;
}void enqueue(Queue *q, int item) {if (q->rear == MAX_SIZE - 1) {printf("Error: Queue is full\n");exit(1);}q->rear++;q->data[q->rear] = item;
}int dequeue(Queue *q) {if (isEmpty(q)) {printf("Error: Queue is empty\n");exit(1);}int item = q->data[q->front];q->front++;return item;
}typedef struct {int data[MAX_SIZE];int top;
} Stack;void initStack(Stack *s) {s->top = -1;
}int isStackEmpty(Stack *s) {return s->top == -1;
}void push(Stack *s, int item) {if (s->top == MAX_SIZE - 1) {printf("Error: Stack is full\n");exit(1);}s->top++;s->data[s->top] = item;
}int pop(Stack *s) {if (isStackEmpty(s)) {printf("Error: Stack is empty\n");exit(1);}int item = s->data[s->top];s->top--;return item;
}void reverseQueue(Queue *q) {if (isEmpty(q)) {return;}Stack s;initStack(&s);while (!isEmpty(q)) {push(&s, dequeue(q));}while (!isStackEmpty(&s)) {enqueue(q, pop(&s));}
}int main() {Queue q;initQueue(&q);int size;scanf("%d", &size);int i;for ( i = 0; i < size; i++) {int item;scanf("%d", &item);enqueue(&q, item);}reverseQueue(&q);while (!isEmpty(&q)) {printf("%d ", dequeue(&q));}printf("\n");return 0;
}

C++


#include<stdio.h>
int main()
{int QUEUE[1000],STACK[1000],i,n,temp,top,front,rear;front=rear=top=-1;scanf("%d",&n);for(i=0;i<n;i++){scanf("%d",&temp);rear++;QUEUE[rear]=temp;}for(i=0;i<n;i++){temp=QUEUE[++front];STACK[++top]=temp;}while(top!=-1){printf("%d ",STACK[top]);top--;}return 0;
}

http://www.hengruixuexiao.com/news/23651.html

相关文章:

  • 用ai做网站搜索排名广告营销怎么做
  • 网站页面设计师杭州seo招聘
  • 如何用html和css做网站河北seo
  • 顾氏网站建设有限公司怎么样seo人员是什么意思
  • 付钱做编程题目的网站做公司网站的公司
  • 小吃加盟网站大全seo推广哪家公司好
  • erlang做网站优势专业网站优化培训
  • 部门网站建设内容方案如何在百度做推广
  • wordpress外贸网站模板百度seo优化排名软件
  • 国外建筑网站app宁波网站制作优化服务公司
  • 息烽做网站公司有哪些百度seo关键词排名优化软件
  • wordpress加入购买功能枫林seo工具
  • 台州做网站的电话优化网站标题名词解释
  • wordpress mysql配置深圳网站seo服务
  • 网站图片怎么做alt网站推广优化公司
  • 化妆品网站设计系统需求的策划书口碑营销策略
  • 360免费wifi怎么用河源网站seo
  • 简洁的网站地图模板网站群发推广软件
  • 手机上自己如何做网站关键词诊断优化全部关键词
  • 那个视频网站好全国seo搜索排名优化公司
  • 汕头网络公司网站建设空间刷赞网站推广
  • 石家庄模板建站代理网站推广的主要方法
  • 个人做的网站能备案吗谷歌海外广告投放
  • 怎么用php做网站sem竞价账户托管
  • 高端网站建设苏州提高工作效率8个方法
  • 自建网站h5纵横seo
  • 网络推广营销实施方案网站seo优化外包
  • 重庆工程建设信息网官网查询宁波seo推广如何收费
  • 免费商城网站建站系统杭州网站seo推广软件
  • 北京网站建设公司东为网站免费优化软件