真正胸怀天下的人,不会计较一城一池的得失,会抓重点,洞察人心,勤学敏思,心强体健,海纳百川,正所谓,国士无双

1.define头文件打标记用法

#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
using namespace std;
int main()
{
    string a="hello kate";
    de(a);
    return 0;
}

 2.string.push_back()

在尾部插入元素,直接+增长字符串,遇到加多个值,或者加int等不是字符类型的会有问题,这时直接push_back,干脆利落

string如果想在字符串中添加数值,需要自己加' ',否则就是要用a+int数值转字母,否则无论是push_back,还是+都会乱码

3.LC1371

 

class Solution {
    int lst[100];
public:
    int findTheLongestSubstring(string s) {
        memset(lst, -1, sizeof(lst));
        int h = 0;
        lst[h] = 0;
        int ans = 0, cur = 0;
        for (char c: s){
            ++cur;
            if (c == 'a') h ^= (1 << 0);
            else if (c == 'e') h ^= (1 << 1);
            else if (c == 'i') h ^= (1 << 2);
            else if (c == 'o') h ^= (1 << 3);
            else if (c == 'u') h ^= (1 << 4);
            if (lst[h] >= 0) 
            {
                ans = max(ans, cur - lst[h]);
                cout<<ans<<" "<<h<<" "<<cur-lst[h]<<endl;
            }
            else lst[h] = cur;
        }
        return ans;
    }
};

 

 

 

 

 

 

 

posted on 2020-03-09 22:32  黑暗尽头的超音速炬火  阅读(169)  评论(0编辑  收藏  举报