03 2017 档案
摘要:我们定义string A,进行g++编译得:输出为空!很奇怪 #include<iostream> #include<string> using namespace std; int main() { string A=""; string str="1234"; int i,j,n=2; for(
阅读全文
摘要: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
阅读全文
摘要:class Solution { public: void FindNumsAppearOnce(vector data,int* num1,int *num2) { if(data.size()>1; ++index; } //这里就是找到最低位的1 *num1=*num2=0; ...
阅读全文
摘要:链接:https://www.nowcoder.com/questionTerminal/8fecd3f8ba334add803bf2a06af1b993 来源:牛客网 class Solution { public: static bool cmp(int a,int b){ string A="
阅读全文
摘要:#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...
阅读全文
摘要:#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...
阅读全文
摘要:#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...
阅读全文
摘要:#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后...
阅读全文
摘要:class Solution {public: bool IsBalanced_Solution(TreeNode* pRoot) { if(NULL==pRoot) return true; if(pRoot->right==NULL&&pRoot->left==NULL) return true
阅读全文
摘要:/* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { } };*/ class Solution { vector > p; ...
阅读全文
摘要: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;...
阅读全文
摘要:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solut...
阅读全文
摘要: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
阅读全文
摘要:class Solution {public: /** * 计算你能获得的最大收益 * * @param prices Prices[i]即第i天的股价 * @return 整型 */ int calculateMax(vector<int> prices) { int len=prices.siz
阅读全文
摘要:#include #include int main() { int j,len1,k,u,result=0,counter=0,len2,i,n; char word[50][50]; char temp[50]; scanf("%d",&n); for(i=0;i<n;i++) scanf("%s",word[i]); ...
阅读全文
摘要:1 #include 2 #include 3 int main() 4 { 5 int minSize,maxSize; 6 int n,i,j,eat=0,result=0; 7 int fishSize[4000]={0}; 8 scanf("%d",&minSize); 9 scanf("%d",&maxSize); 10 scanf...
阅读全文

浙公网安备 33010602011771号