摘要: 我们定义string A,进行g++编译得:输出为空!很奇怪 #include<iostream> #include<string> using namespace std; int main() { string A=""; string str="1234"; int i,j,n=2; for( 阅读全文
posted @ 2017-03-30 22:56 爱编程的小羊 阅读(367) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: string LeftRotateString(string str, int n) { int len = str.length(); if(len == 0) return ""; n=n%len; str+=str; return str.su 阅读全文
posted @ 2017-03-30 22:51 爱编程的小羊 阅读(255) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: void FindNumsAppearOnce(vector data,int* num1,int *num2) { if(data.size()>1; ++index; } //这里就是找到最低位的1 *num1=*num2=0; ... 阅读全文
posted @ 2017-03-30 20:59 爱编程的小羊 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 链接: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) 编辑