- 博客(40)
- 问答 (1)
- 收藏
- 关注
原创 串的动态存储操作
该算法虽然是使用动态内存分配的方法实现,但因其存储单元的地址是连续的,所以本质上还是属于顺序存储。#include #include #include #define MAX 225using namespace std;typedef struct{ char* base; int lengh;}qstring,*pstring;/**************
2016-08-31 19:22:03
553
原创 串的静态顺序存储基本操作
在C语言中没有专门的字符串变量,通常用一个字符数组来存放一个字符串。字符串总是以'\0'作为串的结束符。因此当把一个字符串存入一个数组时,也把结束符 '\0'存入数组,并以此作为该字符串是否结束的标志。有了'\0'标志后,就不能再用字符数组的长度来判断字符串的长度了。#include #include #define MAXSIZE 225using namespace std;t
2016-08-31 17:38:35
981
原创 斐波那契
普通算法和当n大于50或者更大的时候的算法优化http://blog.csdn.net/woshisap/article/details/7566946
2016-08-30 16:04:12
213
原创 3.21(双向栈)
因为top0和top1都指向最后一个元素的下一个位置,所以最好不要把数组占满,如存储6个数,最好开一个7个位置的数组。#include #include using namespace std;typedef struct stack{ int* base; int top[2]; int size;}qstack,*pstack;void init(pstac
2016-08-30 15:32:00
731
原创 3.12(反转单结点)
#include #include #define MAX 5using namespace std;typedef struct node{ int num; struct node* pnext;}qnode,*pnode;pnode init(){ pnode head; head=(pnode)malloc(sizeof(qnode));
2016-08-30 14:31:04
246
原创 3.15(自调整表)
数组实现#include #include #define MAX 5int k=0,t=0;using namespace std;typedef struct node{ int* base; int lengh; int size;}qnode,*pnode;void init(pnode list){ list->base=(int*)
2016-08-30 14:03:36
1256
原创 基数排序(链表)
#includeusing namespace std;typedef struct Node{ int data; struct Node *next;}LNode;void Initiate(LNode **head){ (*head)=(LNode*)malloc(sizeof(LNode)); (*head)->next=NULL;}v
2016-08-29 19:17:15
967
原创 3.11
#include #include #define MAX 8using namespace std;typedef struct node{ int num; struct node* pnext;}qnode,*pnode;pnode init(){ int num_; int size=MAX; pnode head,p,q;
2016-08-29 12:51:21
335
原创 3.10
#include #include #define MAX 8using namespace std;typedef struct node{ int num; struct node* pnext;}qnode,*pnode;pnode init(){ int num_; int size=MAX; pnode head,p,q;
2016-08-29 12:31:16
306
原创 3.6
#include #include #define MAX 5using namespace std;typedef struct node{ int num; int mi; struct node* pnext;}qnode,*pnode;pnode init(){ int size=MAX,num_,mi_; pnode head,p,
2016-08-29 11:03:15
317
原创 3.4 3.5
#include #include #define MAX 5using namespace std;typedef struct node{ int* base; int lengh; int size;}qnode,*pnode;void init(qnode &head){ head.base=(int*)malloc(MAX*sizeof(i
2016-08-29 10:31:48
337
原创 3.3
——————————a————————#include #include #define MAX 8using namespace std;typedef struct node{ int num; struct node* pnext;}qnode,*pnode;pnode init(){ int i=MAX,num_; pnode head,
2016-08-29 09:52:57
348
原创 3.2
#include #include using namespace std;typedef struct node{ int num; struct node* pnext;}qnode,*pnode;pnode init(int n){ int i=n; int num_; pnode head,p,q; head=(pnode)ma
2016-08-28 21:22:21
310
原创 98-12
#include #include using namespace std;#define MAX 8int i=1;typedef struct node{ int num; struct node* pnext;}qnode,*pnode;pnode init(){ int i=MAX; int num_; pnode head,p,
2016-08-28 18:05:13
386
原创 98-10(fibonacci)
#include #include #include using namespace std;int fabonacci (int n){ int sum; if(n==1) { sum=1; } else if(n==0) { sum=0; } else if(n>1) {
2016-08-28 16:24:24
313
原创 98-7
({[入栈 )}]于栈顶比较#include #include #include using namespace std;typedef struct node{ char c; struct node* pnext;}qnode,*pnode;typedef struct stack{ pnode top; pnode botton;}qstac
2016-08-28 16:14:11
395
原创 98-6(栈-回文的使用)
#include #include #include using namespace std;typedef struct node{ char c; struct node* pnext;}qnode,*pnode;typedef struct stack{ pnode top; pnode botton;}qstack,*pstack;voi
2016-08-28 15:13:39
363
原创 关于指针和地址的问题///////
当定义栈,链表,队列的时候,参数的传递可食 pstack 或 qstack &s,但是不管如何定义参数,实参都需要定义成qstack s,使用时如果是第一个形参,则需要加&,否则不需要加&
2016-08-28 14:59:49
358
原创 98-5(进制转换)
#include #include #include using namespace std;typedef struct node{ int num; struct node* pnext;}qnode,*pnode;typedef struct stack{ pnode top; pnode botton;}qstack,*pstack;vo
2016-08-28 13:51:52
399
原创 队列的使用(动态)
#include #include #include using namespace std;typedef struct node//链式队列结点类型{ int num; struct node* pnext;}qnode,*pnode;typedef struct queue//链式队列类型{ pnode front; pnode rear;}
2016-08-28 10:54:59
424
原创 队列的使用(静态数组)
#include #include #include using namespace std;typedef struct queue{ int* base; int front; int rear;}queue;//初始化void init(queue &q,int size){ q.base=(int*)malloc(size*sizeof(i
2016-08-27 23:00:49
357
原创 栈的应用-括号的匹配
#include #include #include using namespace std;typedef struct node{ char AL; struct node* next;}qnode,*pnode;typedef struct stack{ pnode top; pnode botton;}qstack,*pstack;voi
2016-08-25 20:18:33
298
原创 顺序栈的基本操作
#include #include #define space 20using namespace std;typedef struct stack{ int* base;//数组 int top; int stacksize;//长度}qstack;void init(qstack &s,int size){ s.base=(int*)malloc
2016-08-25 18:24:49
638
原创 16-20
#include #include using namespace std;typedef struct node{ int num; struct node* next; struct node* piror;}NODE,*PNODE;PNODE creat_(int n){ int num_; PNODE head,p,q; hea
2016-08-25 15:03:30
198
原创 16-18
#include #include using namespace std;typedef struct node{ int num; struct node* next;}NODE,*PNODE;PNODE creat_(int n)//建立循环双向链表{ int num_; PNODE head,p,q; head=(PNODE)mallo
2016-08-25 14:34:28
209
原创 61-16(*)
//注意(1)最小的数字可能不止一个 如 2 3 4 1 1 1 6//注意 (2)最小的数字如果在末位怎么办//注意(3)最小的数字如果在开头怎么办#include #include using namespace std;typedef struct node{ int num; struct node* next;}NODE,*PNODE;PNODE cre
2016-08-25 14:20:23
329
原创 61-13
//使用连续表#include #include using namespace std;typedef struct list{ int *base; int lengh; int listsize;}qlist;void creat_(qlist &list,int n){ list.base=(int*)malloc(n*sizeof(int
2016-08-25 12:38:36
252
原创 61-14
#include #include using namespace std;typedef struct node{ int num; struct node* prior; struct node* next;}NODE,*PNODE;PNODE creat_(int n)//建立循环双向链表{ int num_; PNODE head,p,
2016-08-25 12:37:46
260
原创 61-12
//使用连续表#include #include using namespace std;typedef struct list{ int *base; int lengh; int listsize;}qlist;void creat_(qlist &list,int n){ list.base=(int*)malloc(n*sizeof(int
2016-08-25 12:16:16
297
原创 61-11
//使用链表是因为本题需要排序#include #include using namespace std;typedef struct node{ int n; struct node* pnext;}NODE,*PNODE;PNODE creat_(int e){ int num; PNODE head,p,q; head=(PNODE)m
2016-08-24 21:42:59
289
原创 链表—约瑟夫环
#include #include typedef struct node{ int num; struct node* next;}NODE,*PNODE;PNODE creat_(int n){ PNODE head,p,q; int num_=1; head=(PNODE)malloc(sizeof(NODE)); head->n
2016-08-24 20:41:51
291
原创 顺序表应用-集合的表示与实现
#include using namespace std;typedef struct list{ int *base; int lengh; int listsize;}qlist;//创建void creat_(qlist &l,int n){ l.base=(int*)malloc(n*sizeof(int)); if(l.base==
2016-08-24 15:24:19
592
原创 循环链表(两个单链表组合成一个循环链表)
//动态链表#include #include typedef struct node{ int a; struct node *next;}NODE,*PNODE;//构建链表PNODE creat_(){ PNODE head,q,p;//定义头指针head,代替头指针球q(头指针不能动) head=(PNODE)malloc(sizeof(NO
2016-08-23 22:51:50
1298
原创 双向链表
//双向链表的基本操作#include using namespace std;typedef struct DLnode{ int num; struct DLnode *prior;//前驱指针 struct DLnode *next;//后驱指针}NODE,*PNODE;//创建双向链表PNODE creat_(){ PNODE head,p,
2016-08-23 22:37:11
266
原创 使用链表的基本操作
//动态链表#include typedef struct node{ int a; struct node *next;}NODE,*PNODE;//构建链表PNODE creat_(){ PNODE head,q,p;//定义头指针head,代替头指针球q(头指针不能动) head=(PNODE)malloc(sizeof(NODE));//分配内
2016-08-23 16:05:31
256
原创 链式栈的基本操作
#include #include //bool的使用#include typedef struct node{ int num; struct node * next;}NODE, *sNODE;typedef struct stack{ sNODE top; sNODE botton;}STACK,*sSTACK;//建立空栈void ini
2016-08-22 13:04:55
689
原创 链表求一元函数和
//#include #include using namespace std;struct node{ int coefficient; int exponent; struct node *next;};struct node *creat()//建立单链表返回链表头指针,此头指针无数据{ struct node *head,*p1,*p2;
2016-08-22 13:04:09
268
原创 基数求和
void radixSort(int *a,int size){ int temp[10][5]={0}; //第一个10表示0到9位数字,第二个20表示a的size int order[10]={0}; int i,j,k; //k表示当前比较的那一位上的具体数字 int n; int p; n=1; while(n <= 100)//由
2016-08-22 13:03:03
471
空空如也
c++自己创建类的一个问题
2017-07-04
TA创建的收藏夹 TA关注的收藏夹
TA关注的人