c++
BJRSR
这个作者很懒,什么都没留下…
展开
-
大数相乘(大数相加的升级版)
#include<iostream>#include<vector>#include<algorithm>using namespace std;int main(){ string s1, s2; s1 = "99900"; s2 = "999000"; vector<int>res,tmp; int res_len =...原创 2020-04-30 16:22:09 · 103 阅读 · 0 评论 -
c++ 动态规化(数字三角形)
int main(){ int n,t; vector<vector<int>>dp; vector<vector<int>>nums; //int a[maxsize][maxsize] = { //{7}, //{3, 8}, //{8,1,0}, //{2,7,4,4}, //{4,5,2,6,5} //}; w...原创 2020-04-20 17:20:12 · 254 阅读 · 0 评论 -
c++分糖果(质因数)+(动态规划)
const int maxsize = 1024;vector<int>prime(maxsize, 0);vector<int>book(maxsize, 0);int cnt;void create(int n){ cnt = 0; int len = sqrt(n); for (int i = 2; i <= len; i++) { ...原创 2020-04-16 17:22:02 · 703 阅读 · 0 评论 -
c++,字符串问题
class solution{private: int a[4]; int b[4];public: void test(string& s) { a[0] = 'G'; a[1] = 'P'; a[2] = 'L'; a[3] = 'T'; for (int i = 0; i < 4; i++) b[i] = 0; int cnt...原创 2020-04-16 16:09:05 · 223 阅读 · 0 评论 -
c++ 判断电量
int main(){ int n, e, d,nums; int k, sum, must, maybe; cin >> n >>e >> d; maybe = must = 0; for (int i = 0; i < n; i++) { cin >> k; sum = 0; for (int j = ...原创 2020-04-16 12:21:35 · 317 阅读 · 0 评论 -
c++ 拍集体照
class node{public: string name; int height;};bool cmp(node s1, node s2){ if (s1.height == s2.height) return s1.name < s2.name; return s1.height > s2.height;}int main(){ ifstream ...原创 2020-04-15 23:46:44 · 276 阅读 · 0 评论 -
c++文件输入字符串和数字
int n, m; ifstream in; in.open("01.txt"); in >> n >> m; string s; int sum; cout << n<<"," << m << endl; for (int i = 0; i < 2*n; i++) { sum = 0; ...原创 2020-04-15 22:28:41 · 768 阅读 · 0 评论 -
c++部落问题
class UnionFindSet{private: vector<int>parent_; vector<int>root_; int nums; public: UnionFindSet(int n) { nums = n; _init_(); }; void _init_() { parent_ = vector<int&...原创 2020-04-15 17:16:07 · 318 阅读 · 0 评论 -
c++剪邮票问题(dfs)
class solution{private: int i1, i2, i3, i4, i5; vector<bool>visit; int dist[4] = { -1,1,-4,4 }; int res; int cnt; void dfs(int index) { if (index >= 5) return; for (int i ...原创 2020-04-15 12:01:20 · 594 阅读 · 0 评论 -
300,最长上升子序列
思想:首先用dp数组对每个元素初始化为1,因为底线为1,然后进行判断,dp[i]=max(dp[j]+1,dp[i]),其中(0=<j<=i<n),然后用max_记录最长的长度,注意:这个最长上升子序列是不连续的,比如上面的可以【2,3,7,101】,【2,5,7,101】,【2,5,7,18】,【2,3,7,18】class Solution {public:...原创 2020-04-13 16:11:21 · 79 阅读 · 0 评论 -
c++,预测题(kmin)
class solution{private: int kmin(vector<int>& nums, int k, int n) { priority_queue<int, vector<int>, less<int>>q; for (int i = 0; i < k; i++) q.push(nums[...原创 2020-04-13 10:54:37 · 242 阅读 · 0 评论 -
c++,kmin,kmax
kmin:大顶堆,把大的元素都去掉,留下小的元素。void kmin(vector<int>nums, int k){ priority_queue<int, vector<int>, less<int>>q;//大顶堆 //先存储前k个 for (int i = 0; i < k; i++) q.push(nums[...原创 2020-04-13 10:17:43 · 620 阅读 · 0 评论 -
c++预测题一
bool cmp(int x, int y){ return x > y;}class solution{private: vector<int>v; void test1(vector<int>& v, int a, int b, int &c) { while (v[b-1]) { for (int i = ...原创 2020-04-12 22:10:33 · 141 阅读 · 0 评论 -
c++最长公共子序列和最长公共子串
解释:最长公共子序列是指:找出两个字符串中的共同子序列,字符可以不连续。比如:s1="abcd",s2="abcefd",则最长子序列为abcd(其中d与abc不连续但是在abc的后面顺序排列)。公式为:(如图)最长公共子串为更为严格的公共子序列。字符必须连续。比如:s1="abcd",s2="abcefd",则最长子串为abc。公式如图:代码一:(最长公共子序列)...原创 2020-04-12 16:01:10 · 1045 阅读 · 0 评论 -
c++,组合递归
class solution{private: vector<vector<int>>res; vector<bool>flag; void test2(int n,int m,int index,vector<int>&p) { if (index == m) { res.push_back(p); ...原创 2020-04-12 09:29:55 · 270 阅读 · 0 评论 -
c++并查集
class UnionFindSet {public: UnionFindSet(int n) { ranks_ = vector<int>(n + 1, 0); parents_ = vector<int>(n + 1, 0); for (int i = 0; i < parents_.size(); ++i) parents_[i]...原创 2020-04-11 21:57:38 · 166 阅读 · 0 评论 -
c++:回旋矩阵(递归)
题目:回旋矩阵class solution{private: vector<vector<int>>plate; void test2(int x, int y, int n,int count) { if (n == 1) { plate[x][y] = count; return; } if (n == 0) retu...原创 2020-04-11 20:39:28 · 522 阅读 · 0 评论 -
oj 上机
#define _CRT_SECURE_NO_WARNINGS#include<iostream>#include<vector>using namespace std;#define max_size 100int main(){ int n; int data[max_size]; //循环输入 while (scanf("%d", &n...原创 2020-04-11 14:19:26 · 238 阅读 · 0 评论 -
ACM标准输入输出C/C++版
https://blog.csdn.net/qiao1245/article/details/53020326?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task转载 2020-03-15 16:53:00 · 75 阅读 · 0 评论 -
哈夫曼树简便版
#define _CRT_SECURE_NO_WARNINGS#include<iostream>#include<algorithm>//算法支持头#include<queue>#include<functional>//greater与less//建立一个优先级小顶堆队列priority_queue<int,vector&l...原创 2019-11-17 22:04:24 · 166 阅读 · 0 评论 -
c++内存区
原创 2019-11-10 20:19:19 · 74 阅读 · 0 评论 -
c ++ 容器写的哈夫曼树的创建
#include<iostream>#include<vector>#include<algorithm>using namespace std;class node{public: node(int w, char name) { this->w = w; this->name = name; }; node() {}...原创 2019-10-18 21:41:32 · 149 阅读 · 0 评论 -
c++容器练习一
#include<iostream>#include<deque>#include<vector>#include<string>#include<algorithm>#include<functional>using namespace std;class Play{public: string nam...原创 2019-10-16 16:33:11 · 405 阅读 · 0 评论