
操作系统
文章平均质量分 81
Buerle
985硕/C++/Golang
展开
-
如何实现rand7等概率实现rand10
class Solution {public: int rand10() { int num=(rand7()-1)*7+rand7(); while(num>10) num=(rand7()-1)*7+rand7(); return num; }};原创 2020-09-06 17:30:24 · 284 阅读 · 0 评论 -
leetcode题解-1的个数
class Solution {public: int hammingWeight(uint32_t n) { int count=0; int mask=1; for(int i=0;i<32;i++) { if(n&&mask!=0) count++; mask<<1; } ...原创 2020-08-29 20:22:21 · 133 阅读 · 0 评论 -
leetcode题解-树的直径(二叉树的最大路径之和)
class Solution{public: int max_length = 0; int depth(TreeNopde *root) { if { int L = depth(root->left); int R = depth(root->right); max_length = max(max_length, L + R); ...原创 2020-08-27 19:42:08 · 284 阅读 · 0 评论 -
leetcode题解-字母词分组
#include <iostream>using namespace std;#include <bits/stdc++.h>class Solution {public: vector<vector<string>> groupAnagrams(vector<string>& strs) { unordered_map<string ,vector<string> ...原创 2020-08-04 20:17:29 · 139 阅读 · 0 评论 -
剑指offer-13题 机器人运动范围
class Solution {public: bool fun(int m ,int n ,int k) { int sum=0; while(m) { sum=sum+m%10; m=m/10; } while(n) { sum=sum+n%10; n=n/10; ...原创 2020-07-30 09:19:23 · 154 阅读 · 0 评论 -
回溯法求解路径
class Solution {public: vector<string>v; void InOrder(TreeNode*root,vector<int>&path) { if(root) { path.push_back(root->val); //到叶子结点 if(root->left==NULL&&...原创 2020-07-06 17:17:28 · 272 阅读 · 0 评论 -
冒泡排序C++
#include <iostream>#include <bits/stdc++.h>using namespace std;void BubbleSort(vector<int> &v){ for (int i = 0; i < v.size(); i++) //次数 { for (int j = 0; ...原创 2020-02-09 21:09:00 · 103 阅读 · 0 评论 -
Linux下的页面置换算法LRU和FIFO算法性能的对比(缺页率)以及Belady异常的观察
#include <stdio.h>#include <unistd.h>#include <sys/types.h>#include <string.h>#include <wait.h>#include <stdlib.h>#include <time.h>int loc_1;原创 2019-01-10 15:24:19 · 2308 阅读 · 0 评论 -
线索二叉树的线索化的实现以及遍历的实现
线索二叉树:(threaded binary tree):n个结点的二叉链表中含有n+1(2n-(n-1)=n+1)个空指针域。利用二叉链表中的空指针域,存放指向结点在某种遍历次序下的前驱和后继结点的指针【注】已知二叉树的节点个数n,那么边的个数n-1。现在给出树节点的定义:class TreeNode{public: TreeNode(int x) { v...原创 2018-07-25 14:03:26 · 352 阅读 · 0 评论 -
页面置换算法LRU+FIFO
#include <stdio.h>#include <unistd.h>#include <sys/types.h>#include <string.h>#include <wait.h>#include <stdlib.h>#include <time.h>int loc_1;原创 2018-06-14 23:23:22 · 584 阅读 · 0 评论