
数据结构学习
mengni123321
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
两个栈实现的一个队列
#include <stack> #include <iostream> using namespace std;template<typename T> class Queue { public: void push(const T &num) { s1.push(num); } T pop() { if (s2.size()原创 2015-03-14 21:17:01 · 330 阅读 · 0 评论 -
一个九位数由1-9数字组成并前N 位被N整除
请将123456789九个数字以特定的顺序排列,组成一个9位数ABCDEFGHI(每个数字只能使用一次),使得: 1.第一位数字组成的整数可以被1整除 2.第一、二位数字组成的整数可以被2整除 3.第一、二、三位数字组成的整数可以被3整除 4.第一、二、三、四位数字组成的整数可以被4整除 …… 9.第一、二、三…九位数字组成的整数可以被9整除#include <stdio.h> void原创 2015-03-14 16:04:15 · 1258 阅读 · 0 评论 -
队列的出队/入队的操作
#include <malloc.h> #include <stdio.h>typedef struct Node { int data; struct Node *pNext; }Node;typedef struct Queue { Node *first; Node *rear; }Queue;Queue *PushBack(Queue *Q,int num)原创 2015-03-14 17:03:33 · 765 阅读 · 0 评论 -
2015蘑菇街笔试题——给定一个英文单词的字符串,按照英文单词的顺序反转输出
#include <string.h> #include <exception>void Reverse(char list[],int begin,int end) { if (begin > end) { throw new std::exception("error"); } char temp; while(begin < end)原创 2015-03-31 14:58:12 · 864 阅读 · 0 评论 -
面试题16:反转链表
#include <string.h> #include <exception>void Reverse(char list[],int begin,int end) { if (begin > end) { throw new std::exception("error"); } char temp; while(begin < end)转载 2015-03-31 15:01:41 · 366 阅读 · 0 评论 -
约瑟夫环问题
约瑟夫环是一个数学的应用问题:已知n个人(以编号1,2,3…n分别表示)围坐在一张圆桌周围。从编号为k的人开始报数,数到m的那个人出列;他的下一个人又从1开始报数,数到m的那个人又出列;依此规律重复下去,直到圆桌周围的人全部出列。#include<stdio.h> #include <stdlib.h> typedef struct xNode { int data; stru原创 2015-03-14 15:51:50 · 328 阅读 · 0 评论 -
队列中取最大值操作问题
1、利用栈中O(1)的时间复杂度取最大值的思路,使用两个栈构建一个队2、列,然后取出两个栈中的较大者即为队列的最大值。#include <stack> #include <exception> #include <iostream> using namespace std;class SatckMax { public: void push(int x) { dat原创 2015-04-25 11:18:32 · 345 阅读 · 0 评论