摘要: 链接:https://www.nowcoder.com/questionTerminal/8fecd3f8ba334add803bf2a06af1b993 来源:牛客网 class Solution { public: static bool cmp(int a,int b){ string A=" 阅读全文
posted @ 2017-03-30 19:41 爱编程的小羊 阅读(199) 评论(0) 推荐(0) 编辑
摘要: #include #include"Coordinate.h" using namespace std; int main() { coor[0].m_iY=5; // coutm_iX=7; p[0].m_iY=9; // coutm_iX=11; p[1].m_iX=15; (++p)->m_iY=17; fo... 阅读全文
posted @ 2017-03-30 16:44 爱编程的小羊 阅读(251) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std; class Teacher { public: Teacher(string name="Jam",int age=1,int m=1000):m_strName(name),m_iAge(age),m_iMax(m) //注意这里没分号,列表初始化赋值不能用=号,用() { cout<<" Te... 阅读全文
posted @ 2017-03-30 14:56 爱编程的小羊 阅读(584) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std; int main() { // string s1="please input your name"; string s2=":"; string s3=s1+s2; //string s5="a"+"b";不允许这样定义!!!至少有有变量 cout<<s3<<endl; string name; g... 阅读全文
posted @ 2017-03-30 12:45 爱编程的小羊 阅读(95) 评论(0) 推荐(0) 编辑
摘要: #include #define Min(a,b) (a>b?b:a) using namespace std; int main() { int a[5]={1,2,3,4,5}; int *p=(int *)(&a+1);//本身数组名就是地址了,也就是数组名就是指针,>取数组的地址,也就是取指针的地址,即p为指向数组的指针(指针的指针),当&a+1,p指向的其实是数组末尾5后... 阅读全文
posted @ 2017-03-30 09:38 爱编程的小羊 阅读(948) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: bool IsBalanced_Solution(TreeNode* pRoot) { if(NULL==pRoot) return true; if(pRoot->right==NULL&&pRoot->left==NULL) return true 阅读全文
posted @ 2017-03-30 00:43 爱编程的小羊 阅读(227) 评论(0) 推荐(0) 编辑
摘要: /* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { } };*/ class Solution { vector > p; ... 阅读全文
posted @ 2017-03-27 12:51 爱编程的小羊 阅读(162) 评论(0) 推荐(0) 编辑
摘要: class Solution { bool judge(vector& a, int left, int right) { if(left>=right) return true; int i=right; //此时数组的right就是根 while(i>left&&a[i-1]>a[right]) --i;... 阅读全文
posted @ 2017-03-27 12:04 爱编程的小羊 阅读(161) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solut... 阅读全文
posted @ 2017-03-23 18:54 爱编程的小羊 阅读(2741) 评论(0) 推荐(0) 编辑
摘要: class BinarySearch {public: int getPos(vector<int> A, int n, int val) { // write code here if(n==0) return -1; else return find(A,0,A.size(),val); } i 阅读全文
posted @ 2017-03-21 19:11 爱编程的小羊 阅读(126) 评论(0) 推荐(0) 编辑