数据结构
菜鸟程序员_随性
这个作者很懒,什么都没留下…
展开
-
十进制整数N转化成B进制整数
通过使用顺序栈的方式将十进制整数N转化成B进制整数;#include <stdio.h>#include <stdlib.h>#define size 100 typedef struct{ int data[size]; int top;}seqstack;seqstack*s;//全局指针变量 void initstack() //置空 { s->top=-1; //所有操作必须先置空} int stackempt原创 2022-04-04 01:07:05 · 910 阅读 · 0 评论 -
用栈判断输入的字符串是否是回文数
1.问题描述回文是指正读反读均相同的字符序列,如“abba”和“abdba”均是回文,但“good”不是回文。试写一个算法判定给定的字符向量是否为回文。(提示:将一半字符入栈)2.题目分析将字符串前一半入栈,然后,栈中元素和字符串后一半进行比较。即将第一个出栈元素和后一半串中第一个字符比较,若相等,则再出栈一个元素与后一个字符比较,……,直至栈空,结论为字符序列是回文。在出栈元素与串中字符比较不等时,结论字符序列不是回文。原创 2022-04-03 23:50:52 · 7088 阅读 · 1 评论 -
十进制纯小数M转化成B进制数小数
通过使用循环队列的方式将十进制纯小数M转化成B进制数;#include <stdio.h>#include <stdlib.h> //malloc需要的头文件; #define size 100typedef struct{ int data[size]; int rear; int front; int count;}cirqueue;cirqueue *q; //全局指针变量 void initqueue() //置队空; {原创 2022-04-03 20:09:30 · 743 阅读 · 0 评论 -
c语言链队的基本操作
该程序包含了链队的置空、判断是否为空、入栈、出栈和取栈顶元素几种基本操作#include <stdio.h>#include <stdlib.h> //malloc和free都需要这个系统库函数头文件; typedef struct node//这里一定要有结构体变量名 { int data; struct node *next; //此处是嵌套的作用,相当于新建了一个该结构体变量的子集,所以需要加上结构体类型名才能实现 ,顺序表则不需要; }q原创 2022-04-02 14:40:19 · 1654 阅读 · 1 评论 -
c语言循环队列的基本操作
该程序包含了置空,判断是否为空,入队,出队,取对头元素等几个基本操作;#include <stdio.h>#include <stdlib.h> //malooc需要的头文件; #define size 100typedef struct{ int data[size]; int rear; int front; int count;}cirqueue;cirqueue *q;void initqueue() //置队空; { q=(cir原创 2022-04-02 14:36:36 · 2777 阅读 · 1 评论 -
c语言链栈的基本操作
该程序包含了链栈的置空、判断是否为空、入栈、出栈和取栈顶元素几种基本操作#include <stdio.h>#include <stdlib.h> //malloc和free都需要这个系统库函数头文件;typedef int datatype;typedef struct node{ datatype data; struct node *next;}stacknode;stacknode *top; int initstack() //置空并且判断原创 2022-04-01 17:03:39 · 1338 阅读 · 0 评论 -
c语言顺序栈的基本操作
该程序包含了顺序栈的置空、判断是否为空、判断是否为满、入栈、出栈和取栈顶元素等几种操作;#include <stdio.h>#define size 100typedef int datatype; //假定栈元素的类型为inttypedef struct{ datatype data[size]; int top;}seqstack;void initstack(seqstack *s) //置空 { s->top=-1; //所原创 2022-04-01 16:59:30 · 2685 阅读 · 1 评论 -
c语言单链表的基本操作
该程序包含了链表的头插法、尾插法、求表长、按位查找、按值查找、插入、删除、销毁等几种操作;#include <stdio.h>#include <stdlib.h> //malloc和free都需要这个系统库函数头文件; typedef struct node//这里一定要有结构体变量名 { char data; struct node *next; }listnode; typedef listnode* linklist; linklist h原创 2022-04-01 16:52:12 · 3555 阅读 · 0 评论 -
c语言顺序表的基本操作
该代码段包含了几种比较常见的顺序表的基本操作,有:求表长,按位取值,按值取位,插入和删除几种方式;#include <stdio.h>#define listsize 100 typedef struct s//这里一定要有结构体变量名 { int data[listsize]; int length; }seplist;//typedef把结构体整体的类型赋予给了seplist; void initlist(seplist *L)//输入的为被定义的sepli原创 2022-04-01 16:46:00 · 1991 阅读 · 1 评论