Skip to content

Instantly share code, notes, and snippets.

View qiaoxu123's full-sized avatar
😄
Coding

xqiao qiaoxu123

😄
Coding
  • China
View GitHub Profile
@qiaoxu123
qiaoxu123 / shared_ptr.cpp
Created July 30, 2022 08:17
参考 [官方链接](https://en.cppreference.com/w/cpp/memory/shared_ptr) 使用多线程来统计计数,等待所有线程结束后自动释放资源。
#include <iostream>
#include <memory>
#include <thread>
#include <chrono>
#include <mutex>
struct Base
{
Base() { std::cout << " Base::Base()\n"; }
// Note: non-virtual destructor is OK here
@qiaoxu123
qiaoxu123 / unique_ptr.cpp
Last active July 30, 2022 06:01
很清楚地说明了 unique_ptr 的几个应用场合,并举了几个很典型的例子来说明。
#include <cassert>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <memory>
#include <stdexcept>
// helper class for runtime polymorphism demo below
struct B
{
@qiaoxu123
qiaoxu123 / Makefile
Last active January 6, 2020 14:41
OOQP的官方示例代码,程序运行和具体分析具体请参考[Ubuntu下OOQP库的安装](https://qiaoxu.coding.me/post/ubuntu-ooqp-install), [Ubuntu环境下OOQP优化库的基本使用](https://qiaoxu.coding.me/post/ubuntu-ooqp-useguide) [//]: # (Uploading ma27-1.0.0.tar.gz)
SHELL = /bin/sh
OOQP=../../..
OOQPINCLUDEDIR=$(OOQP)/include
OOQPLIBDIR=$(OOQP)/lib
CXX = c++
CXXFLAGS =-O
// A C++ Program to implement A* Search Algorithm
#include<bits/stdc++.h>
using namespace std;
#define ROW 9
#define COL 10
// Creating a shortcut for int, int pair type
typedef pair<int, int> Pair;
"""
A* grid planning
author: Atsushi Sakai(@Atsushi_twi)
Nikos Kanargias ([email protected])
See Wikipedia article (https://en.wikipedia.org/wiki/A*_search_algorithm)
"""
#include "stdafx.h"
#include "Astar.h"
int map[101][101] =
{
{0,0,0,1,0,1,0,0,0},
{0,0,0,1,0,1,0,0,0},
{0,0,0,0,0,1,0,0,0},
{0,0,0,1,0,1,0,1,0},
{0,0,0,1,0,1,0,1,0},
{0,0,0,1,0,0,0,1,0},
import sys
import time
import numpy as np
from matplotlib.patches import Rectangle
import point
import random_map
// C / C++ program for Dijkstra's shortest path algorithm for adjacency
// list representation of graph
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
// A structure to represent a node in adjacency list
struct AdjListNode
{
// Program to print BFS traversal from a given
// source vertex. BFS(int s) traverses vertices
// reachable from s.
#include<iostream>
#include <list>
using namespace std;
// This class represents a directed graph using
// adjacency list representation
@qiaoxu123
qiaoxu123 / c_const.c
Created July 31, 2019 05:43
[参考链接](https://qiaoxu123.github.io/post/3-C++Courses/) `const`变量在C/C++中有较大的区别。对于C语言来讲,`const`定义仅仅是一个只读变量,可以通过指针进行修改。而C++中对`const`参数进行了升级处理,使用类似宏定义的方式进行了常量化。为了向上兼容,也保留了原有的一些性质。具体看参考链接。
#include<stdio.h>
int main(){
const int c = 0;
int* p = (int*)&c;
printf("Begin...\n");
*p = 5;
printf("c = %d\n",c);
printf("End...\n");