摘要: 1 class Solution { 2 public: 3 int removeElement(int A[], int n, int elem) { 4 int *p=A,*e=&A[n-1]; 5 int i,num=n; 6 for(i=0;i<n;i++){ ... 阅读全文
posted @ 2014-11-22 14:33 xcw0754 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 int removeDuplicates(int A[], int n) { 4 int *s=&A[0],*e=&A[0]; //s指向开头第一个,e往后遍历相同的 5 int t,i,j=n; 6 fo... 阅读全文
posted @ 2014-11-21 23:45 xcw0754 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne... 阅读全文
posted @ 2014-11-19 12:53 xcw0754 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.cnblogs.com/xFreedom/archive/2011/05/16/2048037.html(部分修改过了) 相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用。但是如果离开了MF... 阅读全文
posted @ 2014-11-18 22:43 xcw0754 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 void push(char c){ //插入结点 4 struct node *n=new struct node; 5 n->nex=0; 6 n->ch=c; 7 n->pre=las... 阅读全文
posted @ 2014-11-18 22:35 xcw0754 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne... 阅读全文
posted @ 2014-11-14 22:17 xcw0754 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 1 void merge(int A[], int m, int B[], int n) { 2 int *a=A,*b=B; 3 int i=0,j=0; 4 if(n==0||m==0){ //针对特殊情况,比如A或B中无元素的情况 5 i... 阅读全文
posted @ 2014-11-12 13:40 xcw0754 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 题意:找到离根结点最近的叶子结点的那一层(设同一层上的结点与根结点的距离相等),返回它所在的层数。方法有:1、递归深度搜索2、层次搜索方法一:递归(无优化) 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * i... 阅读全文
posted @ 2014-11-09 21:32 xcw0754 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 int reverse(int x) { 4 int e,s,num,k=0; 5 num=x; 6 e=0; 7 if(x<0) 8 nu... 阅读全文
posted @ 2014-11-08 22:06 xcw0754 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 string countAndSay(int n) { 4 if(n==1) return "1"; 5 string str0="",str1="1"; 6 int i,t,count; 7 ... 阅读全文
posted @ 2014-11-08 22:00 xcw0754 阅读(176) 评论(0) 推荐(0) 编辑