- 博客(40)
- 问答 (1)
- 收藏
- 关注
原创 串的动态存储操作
该算法虽然是使用动态内存分配的方法实现,但因其存储单元的地址是连续的,所以本质上还是属于顺序存储。 #include #include #include #define MAX 225 using namespace std; typedef struct { char* base; int lengh; }qstring,*pstring; /**************
2016-08-31 19:22:03 521
原创 串的静态顺序存储基本操作
在C语言中没有专门的字符串变量,通常用一个字符数组来存放一个字符串。字符串总是以'\0'作为串的结束符。因此当把一个字符串存入一个数组时,也把结束符 '\0'存入数组,并以此作为该字符串是否结束的标志。有了'\0'标志后,就不能再用字符数组的长度来判断字符串的长度了。 #include #include #define MAXSIZE 225 using namespace std; t
2016-08-31 17:38:35 930
原创 斐波那契
普通算法和当n大于50或者更大的时候的算法优化 http://blog.csdn.net/woshisap/article/details/7566946
2016-08-30 16:04:12 194
原创 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 692
原创 3.12(反转单结点)
#include #include #define MAX 5 using 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 221
原创 3.15(自调整表)
数组实现 #include #include #define MAX 5 int 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 1178
原创 基数排序(链表)
#include using 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 922
原创 3.11
#include #include #define MAX 8 using 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 301
原创 3.10
#include #include #define MAX 8 using 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 275
原创 3.6
#include #include #define MAX 5 using 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 294
原创 3.4 3.5
#include #include #define MAX 5 using 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 310
原创 3.3
——————————a———————— #include #include #define MAX 8 using 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 318
原创 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 292
原创 98-12
#include #include using namespace std; #define MAX 8 int 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 363
原创 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 289
原创 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 353
原创 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 333
原创 关于指针和地址的问题///////
当定义栈,链表,队列的时候,参数的传递可食 pstack 或 qstack &s,但是不管如何定义参数,实参都需要定义成qstack s,使用时如果是第一个形参,则需要加&,否则不需要加&
2016-08-28 14:59:49 332
原创 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 372
原创 队列的使用(动态)
#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 391
原创 队列的使用(静态数组)
#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 320
原创 栈的应用-括号的匹配
#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 270
原创 顺序栈的基本操作
#include #include #define space 20 using 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 607
原创 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 173
原创 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 189
原创 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 309
原创 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 224
原创 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 235
原创 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 269
原创 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 265
原创 链表—约瑟夫环
#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 260
原创 顺序表应用-集合的表示与实现
#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 551
原创 循环链表(两个单链表组合成一个循环链表)
//动态链表 #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 1242
原创 双向链表
//双向链表的基本操作 #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 238
原创 使用链表的基本操作
//动态链表 #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 225
原创 链式栈的基本操作
#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 648
原创 链表求一元函数和
// #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 237
原创 基数求和
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 434
空空如也
c++自己创建类的一个问题
2017-07-04
TA创建的收藏夹 TA关注的收藏夹
TA关注的人