随笔分类 -  Algorithms

摘要:/** * Definition for a binary tree node. * function TreeNode(val) { * this.val = val; * this.left = this.right = null; * } *//** * @param {Tre... 阅读全文
posted @ 2015-10-05 09:18 calmound 阅读(185) 评论(2) 推荐(0) 编辑
摘要:/** * 题意:将0挪到末尾,并且不改数组中原有元素的顺序 * 解析:找到0元素,然后寻找其后面非0的元素,进行交换位置 * @param {number[]} nums * @return {void} Do not return anything, modify nums in-place i... 阅读全文
posted @ 2015-10-04 21:22 calmound 阅读(257) 评论(0) 推荐(0) 编辑
摘要:/** *题意:判断两棵二叉树 * Definition for a binary tree node. * function TreeNode(val) { * this.val = val; * this.left = this.right = null; * } *//** ... 阅读全文
posted @ 2015-10-04 20:56 calmound 阅读(217) 评论(0) 推荐(0) 编辑
摘要:#include#include#includeusing namespace std;struct ListNode{ int data; ListNode *lchild,*rchild;};ListNode* Createbst(){ int data; scanf("... 阅读全文
posted @ 2014-08-30 22:00 calmound 阅读(195) 评论(0) 推荐(0) 编辑
摘要:例如“abc”输出a,b,c,ab,ac,bc,abc#includevoid DFS(char str[],char ss[],int pos,int cnt,int n){ if(n==pos) { ss[cnt]='\0'; if(cnt!=0) pri... 阅读全文
posted @ 2014-08-30 18:23 calmound 阅读(1536) 评论(0) 推荐(0) 编辑
摘要:#includevoid ShellSort(int array[],int length){ int i,j,h,temp; for(h=length/2;h>0;h=h/2) { for(i=h;i=0;j-=h) { ... 阅读全文
posted @ 2014-08-30 17:41 calmound 阅读(123) 评论(0) 推荐(0) 编辑
摘要:#includevoid AdjustMinHeap(int *a,int pos,int len){ int temp,child; for(temp=a[pos];pos*2+1=0;i--) AdjustMinHeap(array,i,len-1); for(i=le... 阅读全文
posted @ 2014-08-30 16:55 calmound 阅读(159) 评论(0) 推荐(0) 编辑
摘要:#include#includeusing namespace std;//日期函数int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};struct date{ int year,month,day;};//判闰年inline int leap(in... 阅读全文
posted @ 2014-08-28 12:16 calmound 阅读(427) 评论(0) 推荐(0) 编辑
摘要:struct ListNode{ int data; ListNode *lchild,*rchild;};void CreateBSTree(ListNode *B2_root,ListNode *BSTree_root){ if(BSTree_root==NULL) ... 阅读全文
posted @ 2014-08-27 21:44 calmound 阅读(1708) 评论(0) 推荐(0) 编辑
摘要:#include#include#includeusing namespace std;void GetNext(char *str,int next[]){ int j,k; j=0;k=-1;next[0]=-1; while(str[j]!='\0') { ... 阅读全文
posted @ 2014-08-25 19:26 calmound 阅读(160) 评论(0) 推荐(0) 编辑
摘要:中缀表达式“9+(3-1)*3+10/2”转化为后缀表达式“9 3 1-3*+ 10 2/+”中缀表达式转后缀表达式的方法:1.遇到操作数:直接输出(添加到后缀表达式中)2.栈为空时,遇到运算符,直接入栈3.遇到左括号:将其入栈4.遇到右括号:执行出栈操作,并将出栈的元素输出,直到弹出栈的是左括号,... 阅读全文
posted @ 2014-08-10 12:15 calmound 阅读(262) 评论(0) 推荐(0) 编辑
摘要:#includevoid InsertSort(int n,int a[]){ int j; for(int i=0;i=0;j--) { if(a[j]>tmp) { a[j+1]=a[j]; ... 阅读全文
posted @ 2014-07-26 10:27 calmound 阅读(139) 评论(0) 推荐(0) 编辑
摘要:#includevoid SelectSort(int n,int a[]){ for(int i=0; i<n; i++) { int MIN=a[i]; int k=i; for(int j=i+1; j<n; j++) { ... 阅读全文
posted @ 2014-07-26 10:07 calmound 阅读(135) 评论(0) 推荐(0) 编辑
摘要:#includevoid BubbleSort(int n,int a[]){ for(int i=0;ia[j+1]) { int tmp=a[j]; a[j]=a[j+1]; a... 阅读全文
posted @ 2014-07-26 09:46 calmound 阅读(130) 评论(0) 推荐(0) 编辑
摘要:#includevoid MergeArray(int first,int mid,int last,int a[]){ int k=0; int i=first,j=mid+1; int n=mid,m=last; int c[100]; while(i<=n && ... 阅读全文
posted @ 2014-07-25 17:29 calmound 阅读(139) 评论(0) 推荐(0) 编辑
摘要:#include#includeusing namespace std;typedef int ElemType;typedef struct Node{ ElemType data; struct Node* next;}*LinkList,Node;LinkList LinkList... 阅读全文
posted @ 2014-07-24 14:48 calmound 阅读(140) 评论(0) 推荐(0) 编辑
摘要:#include#include#includetypedef int Item;typedef struct node* PNode;typedef struct node{ Item data; PNode next;}Node;typedef struct{ PNode fr... 阅读全文
posted @ 2014-05-20 18:03 calmound 阅读(316) 评论(0) 推荐(0) 编辑
摘要:学习地址: http://hi.baidu.com/vfxupdpaipbcpuq/item/dce4e6f8a8c45f13d7ff8cda 阅读全文
posted @ 2013-07-16 08:41 calmound 阅读(177) 评论(0) 推荐(0) 编辑
摘要:void eular(){ memset(vis,0,sizeof(vis)); vis[0]=vis[1]=1; for(i=2;i*i 1) res = res / x * (x - 1); return res;} 阅读全文
posted @ 2013-07-14 11:21 calmound 阅读(269) 评论(0) 推荐(0) 编辑
摘要:#include#include#include#includeusing namespace std;const int MN=2011;vectoredge[MN];vectorSCC[MN];stacks;int low[MN],dfn[MN];int instack[MN],stap[MN]... 阅读全文
posted @ 2013-07-14 10:22 calmound 阅读(218) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示