This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <algorithm> | |
#include <memory> | |
#include <string> | |
using namespace std; | |
__attribute((constructor))void before(){ | |
cout << "before main" << endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstring> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
const int N = 9, M = 1 << N; | |
int ones[M], map[M]; | |
// ones存的是, 一个数,的二进制中,有几个1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% 变量的变量 | |
data = [2, 3, 4, 5]; | |
for m = 1 : 4 | |
name_string = ['s' num2str(m) ' = data' '(' num2str(m) ')']; | |
eval(name_string) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
元素去重 | |
*/ | |
vector<int> alls; //存储所有值 | |
sort(alls.begin(), alls.end()); //排序 | |
alls.erase(unique(alls.begin(), alls.end()), alls.end()); //去除重复元素 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
整数n的二进制表示下第k为是几 | |
右移k位 然后 与运算1 | |
*/ | |
n >> k & 1; | |
/* | |
x -> 表示整数n的二进制,但实际使用的时候, 传入n就行 | |
lowbit(x): 返回x的最后一位1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
C++大数运算去除前导0 | |
vector<int> c; // c的数据类型 | |
如果要用c表示一个大数, eg: "123456" | |
则存储方式为(倒着存): | |
[6, 5, 4, 3, 2, 1] | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get install -y build-essential gdebi | |
mkdir -p ~/tmp | |
wget https://github.com/nomumu/Kinetic4RPiZero/releases/download/v_2017-10-15/rpi-zerow-kinetic_1.0.0-1_armhf.zip | |
unzip rpi-zerow-kinetic_1.0.0-1_armhf.zip | |
sudo gdebi rpi-zerow-kinetic_1.0.0-1_armhf.deb | |
sudo /opt/ros/kinetic/initialize.sh |