Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Yizheng Zhang Privilger

🎯
Focusing
View GitHub Profile
@Privilger
Privilger / exec_before_main.cpp
Created Sep 6, 2020
a code run before main() function.
View exec_before_main.cpp
#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 Mar 4, 2020
玩数独, acwing 166题
View acwing_166.cpp
#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 / magic_matlab.m
Created Feb 26, 2020
Matlab编程技巧
View magic_matlab.m
%% 变量的变量
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 Feb 19, 2020
C++ STL 使用技巧
View a.cpp
/*
元素去重
*/
vector<int> alls; //存储所有值
sort(alls.begin(), alls.end()); //排序
alls.erase(unique(alls.begin(), alls.end()), alls.end()); //去除重复元素
@Privilger
Privilger / bit_operate.cpp
Last active Mar 4, 2020
整数n的二进制运算操作
View bit_operate.cpp
/*
整数n的二进制表示下第k为是几
右移k位 然后 与运算1
*/
n >> k & 1;
/*
x -> 表示整数n的二进制,但实际使用的时候, 传入n就行
lowbit(x): 返回x的最后一位1
@Privilger
Privilger / big_num_operate.cpp
Last active Feb 18, 2020
C++大数运算去除前导0
View big_num_operate.cpp
/*
C++大数运算去除前导0
vector<int> c; // c的数据类型
如果要用c表示一个大数, eg: "123456"
则存储方式为(倒着存):
[6, 5, 4, 3, 2, 1]
*/
@Privilger
Privilger / ros_kinetic_install_raspizero.bash
Created Sep 1, 2018 — forked from Tiryoh/ros_kinetic_install_raspizero.bash
ROS Kinetic installation on Raspberry Pi Zero/Raspberry Pi Zero W
View ros_kinetic_install_raspizero.bash
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