- 博客(9)
- 收藏
- 关注
原创 用递归函数和栈逆序一个栈_C++题解
题目:用递归函数和栈逆序一个栈OJ地址:传送门题解用栈实现输出反转#include <iostream>#include <stack>using namespace std;stack<int> st;int main(){ int N, X; cin>>N; while(N--) { cin>>X; st.push(X); } while
2021-03-16 17:51:10
285
原创 由两个栈组成的队列_C++题解
题目名称:由两个栈组成的队列题目地址: 传送门题解一个入队栈st1,一个出队栈st2,每次Peek和Poll前,判断出队栈st2是否为空,若为空,则将st1传入st2(不保留st1)#include <iostream>#include <stack>#define MAXN 1000010using namespace std;stack<int> st1, st2;void Trans(stack<int> &s1, stac
2021-03-16 17:44:16
143
原创 设计getMin功能的栈_C++题解
题目名称:设计getMin功能的栈题目地址:传送门题解用两个容器,一个顺序容器,使用数组;一个关联容器,使用map。用数组构造栈,用于Push和Pop。每Push一个元素进去,map中关键字对应的值加1(若map中没有此关键字,创建该键值对)。每Pop一个元素,map中冠电子对应的值减1(若map中此关键字的值减为0,删除该键值对)。每次GetMin,输出map中第一个键值对的关键字。Push, Pop代价O(logN)GetMin代价O(1)#include <iostream>
2021-03-16 17:38:17
164
原创 高光谱分类 Hyperspectral image (HSI) classification
HSI模型获得数据、引入基本函数库! wget http://www.ehu.eus/ccwintco/uploads/6/67/Indian_pines_corrected.mat! wget http://www.ehu.eus/ccwintco/uploads/c/c4/Indian_pines_gt.mat! pip install spectralimport numpy as npimport matplotlib.pyplot as pltimport scipy.io
2020-12-17 16:58:45
3695
6
原创 猫狗大战——VGG
import numpy as npimport matplotlib.pyplot as pltimport osimport torchimport torch.nn as nnimport torchvisionfrom torchvision import models,transforms,datasetsimport timeimport json# 判断是否存在GPU设备device = torch.device("cuda:0" if torch.cuda.is_ava
2020-11-20 16:09:13
365
原创 备用:Dijkstra C++实现
typedef struct{ int distance, path; bool visited;}Grap;typedef struct{ int to, cost;}Edge;Grap G[maxn];vector<Edge> E[maxn];void Dijkstra(Grap* G, int S, int T){ G[S].distance = 0; heap.insert(S); while(!heap.empty()) { int V = heap.
2020-11-05 20:45:10
1029
原创 PAT 1005 后缀数组
#include <iostream>#include <unordered_map>#include <map>#include <cstring>using namespace std;struct SuffixArray{//后缀数组 #ifndef _SA_ #define maxn 1200000 #define maxcnt 270 #endif int n; //字符串长度 int sa[maxn]; //后
2020-10-02 09:07:38
1571
1
原创 十大排序算法C++实现(C++11)
#include <cstdio>#include <iostream>using namespace std;//c++11 使用 bool rule1(int a, int b){ return a<b;}bool rule2(int a, int b){ return a>b;}void swap(auto &a, aut...
2020-03-08 20:05:11
304
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人