C/C++
勇敢牛牛_
不念往昔,无惧将来。
展开
-
数据结构:实验三(2)(有序表)
#include "stdafx.h"#include "SeqList.h"//自定义头文件int main(){ SeqList myList; ListInitiate(&myList);//初始化 SortListInerst(&myList, 1);//有序插入顺序表 SortListInerst(&myList, 2); SortListIne原创 2017-03-07 21:29:41 · 609 阅读 · 0 评论 -
数据结构(C语言)之链表(单、双链表)
数据结构链表的基本操作 1、单链表 2、循环单向链表 3、循环双向链表 函数最后一个参数代表链表类型: 1 SinglyLinkedList(单链表) 2 CircularSinglyLinledList(循环单链表) 3 DoublyLinkedList(双向链表)#include "stdafx.h"#include "SLList.h"int mai原创 2017-03-11 21:15:53 · 592 阅读 · 0 评论 -
数据结构:实验5(堆栈判断回文数)
#include "SeqStack.h"//堆栈头文件void isHuiWen(int str[], int n){ SeqStack s; int x;//出栈值 StackInitiate(&s);//初始化堆栈 for (int i = 0; i < n; i++) { StackPush(&s, str[i]);//数组入栈原创 2017-03-27 20:22:36 · 2899 阅读 · 1 评论 -
数据结构:利用栈T将栈S升序
#include "SeqStack.h"//升序栈SeqStack YouXuZhan(SeqStack *s){ SeqStack t;//临时栈 StackInitiate(&t);//初始化 int x;//s栈出栈值 int y;//t栈出栈值 while (StackNotEmpty(*s)) { StackPop(s,原创 2017-03-30 21:18:40 · 574 阅读 · 0 评论 -
数据结构:实验六(单循环链表实现链式队列)
单循环链表实现的链式队列,只设头指针,不设尾指针#include "LLQueue.h"int main(){ LLQueue lq; QueueInit(&lq); for (int i = 0; i < 5; i++) { QueueAppend(&lq, i + 1); printf("%d 入队列\n", i + 1);原创 2017-04-02 18:05:34 · 1968 阅读 · 1 评论 -
数据结构:单链表就地逆置
以Head节点当作第三变量,不单独开辟新的节点空间。void Inverse(SLNode *head) { SLNode *p, *q; p = head->next; head->next = NULL; while (p != NULL) { q = p; p = p->next; q->next = head->原创 2017-03-16 20:30:06 · 3113 阅读 · 1 评论 -
数据结构:练习题
题目:已知一棵树的度为m,且有n1个度为1的节点,有n2个度为2的节点……有nm个度为m的节点,求这棵树的叶节点个数。解:设总节点个数为n,叶节点个数为n0,分支数为M 则总结点个数n=n0+n1+n2+…+nm ①除根节点外,其他节点均由一个或多个分支进入所以:M=n-1 ②又度为0的分支数为0,度为1的分支数为1,度为2的分支数为2,…,度为m的分支原创 2017-04-13 16:16:10 · 411 阅读 · 0 评论 -
数据结构:实验七——二叉树的层序遍历
二叉树的层序遍历:二叉树结构: #include "stdafx.h"#include "BiTree.h"//二叉树头文件[点击下载](http://download.csdn.net/detail/wxgxgp/9825018)#include "SeqCQueue.h"//队列头文件[点击下载](http://download.csdn.net/detail/wxgxgp/98250原创 2017-04-25 15:28:09 · 812 阅读 · 0 评论 -
xxx的纠错(1)
int LsitFind(SeqList *L, int x) { int i; for (i = 0; i < 5; i++) { if (x == L->list[i]) return i; else return -1; }}int main() { SeqList *list1原创 2017-03-07 21:19:40 · 480 阅读 · 0 评论 -
数据结构:实验5(求堆栈元素和)
#include "stdio.h"#include "SeqStack.h"int StackSum(SeqStack *s) //求和{ int x=0; int sum = 0; while (StackNotEmpty(*s)) { StackPop(s, &x); sum += x; } return su原创 2017-03-27 21:42:07 · 640 阅读 · 0 评论 -
数据结构:链表的创建和打印
#include "stdafx.h"struct node { int num; struct node *next;//指向下一节点};//创建链表struct node * creat() { struct node *head, *temp, *newp;//分别表示头节点、中间节点、新节点 int n;//节点数据 head = temp =原创 2017-02-27 20:41:43 · 1790 阅读 · 0 评论 -
数据结构:链表的增加、插入和删除
#include "stdafx.h"//define nodestruct node {//node int num; int number; struct node *next;//next lnode};//creat a null linked liststruct node *creat() { struct node *head, *temp;原创 2017-02-28 19:48:48 · 1065 阅读 · 0 评论 -
数据结构:实验一
// 实验一.cpp : 定义控制台应用程序的入口点。///* 1.有长为4的一维整形数组,在主函数中输入数组元素,调用函数计算所有元素的 和并在主函数中输出(分别用数组名和数组元素作为函数参数)*/#include "stdafx.h"int add_arrName(int arr[], int length);int add_arrElement(int a, int原创 2017-02-20 19:22:00 · 788 阅读 · 0 评论 -
数据结构:实验二
// 实验二.cpp :///*1.定义student结构体,包含姓名、学号、C成绩、VB成绩、数学成绩和英语成绩,并计算平均成绩,通过调用函数输出平局成绩。2.函数完成二维数组的最小值查找,并在主函数中输出(用指针实现)。*/#include "stdafx.h"#include "string"#include "iostream"using namespace std;//原创 2017-02-22 12:25:49 · 541 阅读 · 0 评论 -
C指针
void int_point();void One_dimensionalArray();void Two_dimensionalArray();int main(){ int_point(); One_dimensionalArray(); Two_dimensionalArray();}//整形指针void int_point(){ int *p;原创 2017-02-22 22:42:05 · 330 阅读 · 0 评论 -
数据结构:栈的基本操作
int main(){ SeqStack MyStack; StackInitiate(&MyStack); for (int i = 0; i < 10; i++) StackPush(&MyStack, i); printf("栈顶元素为:%d\n", StackTop(&MyStack)); int pop; StackPop(原创 2017-03-19 20:58:20 · 529 阅读 · 0 评论 -
数据结构:实验二(修改后)
2、有一个结构体类型,其中包含两个成员:一个是抽象类型一维数组a[5] ,另一个是数组之和sum,请编程并指定抽象数据类型为int,调用子函数算出sum并在主函数中输出显示#include "stdafx.h"typedef int a[5];typedef struct student { a arry; int sum;}student;void sum(student原创 2017-02-27 20:27:25 · 440 阅读 · 0 评论 -
数据结构:实验三(查找顺序表元素)
编写函数FindList(L,x)查找顺序表中的值为x的数据并返回索引,如果没找到则返回-1#include "stdafx.h"#include "SeqList.h"int main(){ SeqList myList ; ListInitiate(&myList);//初始化顺序表,长度为0 for (int i = 0; i < 10; i++) {//赋初值原创 2017-03-07 12:49:55 · 3980 阅读 · 0 评论 -
数据结构:实验八(图的操作及入度和出度的计算)
题目:自己画一张图,建立邻接矩阵,并求出每个顶点的度 #include "AdjMGraph.h"void CreatGraph(AdjMGraph *g, DataType V[],int n, RowColWeight E[], int e)//创建图{ Initiate(g, n); for (int i = 0; i < n; i++) InsertVe原创 2017-05-09 21:49:21 · 7950 阅读 · 1 评论