Skip to content

Instantly share code, notes, and snippets.

View Privilger's full-sized avatar
🎯
Focusing

Yizheng Zhang Privilger

🎯
Focusing
View GitHub Profile
@Privilger
Privilger / exec_before_main.cpp
Created September 6, 2020 08:30
a code run before main() function.
#include <iostream>
#include <algorithm>
#include <memory>
#include <string>
using namespace std;
__attribute((constructor))void before(){
cout << "before main" << endl;
}
@Privilger
Privilger / acwing_166.cpp
Created March 4, 2020 07:14
玩数独, acwing 166题
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 9, M = 1 << N;
int ones[M], map[M];
// ones存的是, 一个数,的二进制中,有几个1
@Privilger
Privilger / bit_operate.cpp
Last active March 4, 2020 06:50
整数n的二进制运算操作
/*
整数n的二进制表示下第k为是几
右移k位 然后 与运算1
*/
n >> k & 1;
/*
x -> 表示整数n的二进制,但实际使用的时候, 传入n就行
lowbit(x): 返回x的最后一位1
@Privilger
Privilger / magic_matlab.m
Created February 26, 2020 03:52
Matlab编程技巧
%% 变量的变量
data = [2, 3, 4, 5];
for m = 1 : 4
name_string = ['s' num2str(m) ' = data' '(' num2str(m) ')'];
eval(name_string)
end
@Privilger
Privilger / a.cpp
Created February 19, 2020 07:20
C++ STL 使用技巧
/*
元素去重
*/
vector<int> alls; //存储所有值
sort(alls.begin(), alls.end()); //排序
alls.erase(unique(alls.begin(), alls.end()), alls.end()); //去除重复元素
@Privilger
Privilger / big_num_operate.cpp
Last active February 18, 2020 15:09
C++大数运算去除前导0
/*
C++大数运算去除前导0
vector<int> c; // c的数据类型
如果要用c表示一个大数, eg: "123456"
则存储方式为(倒着存):
[6, 5, 4, 3, 2, 1]
*/
@Privilger
Privilger / ros_kinetic_install_raspizero.bash
Created September 1, 2018 06:52 — forked from Tiryoh/ros_kinetic_install_raspizero.bash
ROS Kinetic installation on Raspberry Pi Zero/Raspberry Pi Zero W
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