- 博客(6)
- 收藏
- 关注
原创 选择排序
#include#includeusing namespace std;int selectSort(int a[],int n){for(int i=1;i<=n;i++)//进行n趟排序{int k=i;for(int j=i;j<=n;j++){if(a[j]>a[k])//从大到小排序{k=j;}}int temp=a[i];a[i]=a[k];a[k]=temp;}return a[n];}int main(){int a[10010
2020-06-15 21:00:05 71
原创 冒泡排序
#include#includeusing namespace std;int main(){int a[10010];int n;cin>>n;for(int i=0;i<n;i++){cin>>a[i];}for(int i=1;i<n-1;i++){for(int j=0;j<n-i;j++){if(a[j]>a[j+1]){int temp=a[j];a[j]=a[j+1];a[j+1]=temp;}}}f
2020-06-15 20:58:49 75
原创 二叉树2的算法
(以下代码非原创)#include<assert.h>#include<string.h>#include<stdlib.h>#include<stdio.h>typedef struct _treenode{int data;struct _treenode *lchild;struct _treenode *rchild;}Tnode,Tree;void binarytree_create(Tree **Root){int a =
2020-06-15 20:57:52 130
原创 二叉树的算法
//二叉树的算法(非原创)//输入为字符#include<stdio.h>#include<stdlib.h>#includeusing namespace std;typedef struct BiTNode{char data;struct BiTNode *lchild,*rchild;}BiTNode,*BiTree;void PreOrderTraverse(BiTree T)//二叉树的先序遍历{if(TNULL)return ;printf
2020-06-15 20:54:36 92
原创 双链表的基本操作
/* 作者邮箱 1372721956@qq.com/#include#includeusing namespace std;struct node{int data;node* prior;node* next;};//尾插法node* create(int a[],int n)//构建双链表//返回值为指针 所以函数加*{node* pre ,p,head;head=new node;head->next=NULL;head->prior=NULL;pre=he
2020-06-12 10:10:04 105
原创 单链表的基本操作
以下代码参考晴神宝典#include#includeusing namespace std;struct node{int data;node* next;};node* create(int a[],int n){node* pre,p,head;head=new node;head->next=NULL;pre=head;for(int i=0;i<n;i++){p=new node;p->data=a[i];p->next=NULL;pre
2020-06-09 11:43:16 80
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人