- 博客(19)
- 收藏
- 关注
转载 汇编语言实现求两个数的最小公约数,平方差,各占和的百分比
按下列要求编程:(1)输入两个小于100的十进制正整数。(2)求出这两个数的所有公约数。(3)求出这两个数的平方差,若是负的要输出负号。(4)计算两个数各占和的百分比,并且按照“ %”的格式输出(小数点后保留两位)。(5)数据的输入和结果的输出都要有必要的提示,且提示独占一行。(6)要使用到子程序。源代码:data segment hh db 0dh,0ah,...
2019-09-15 20:05:00
1134
转载 STL和基本数据结构
一、容器1、vectorvector 是STL的动态数组,索引可以在常数时间内完成,插入或删除中间某一项需要线性时间,时间复杂度是O(n)vector<int> b(a); //用a定义bvector<int> a(100); //a有100个值为0的元素vector<int> a(100, 6) //a有100个值为6的元素 ve...
2019-09-15 01:13:00
169
转载 1LL(1ll) 与 std::to_string()
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */...
2019-09-15 01:03:00
341
转载 Day-10-高级数据结构(Trie树、并查集、线段树)Leetcode-208, 211, 547, 307
//Trie 树节点表示(字典树)#include <stdio.h># define TRIE_MAX_CHAR_NUM 26struct TrieNode { TrieNode* child[TRIE_MAX_CHAR_NUM]; // Trie 树的指针数组 bool is_end; TrieNode() : is_...
2019-09-15 00:57:00
132
转载 Day-09-动态规划 Leetcode-70, 198, 53, 32, 120, 300, 64, 174
例一:LeetCode70/** You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? */#...
2019-09-15 00:51:00
240
转载 Day-08-搜索 Leetcode-200, 127, 126, 473, 407
例一:LeetCode200void DFS(std::vector<std::vector<int>>& mark, std::vector<std::vector<char>>& grid, int x, int y) { mark[x][y] = 1; static ...
2019-09-15 00:44:00
93
转载 Day-07-哈希表和字符串 Leetcode-409, 290, 49, 3, 187, 76
// //最简单的哈希,字符哈希#include <stdio.h>#include <string>int main() { int char_map[128] = { 0 }; std::string str = "abcdefgaaxxy"; for (int i = 0; i < str.l...
2019-09-15 00:37:00
99
转载 Day-06-二分搜索和二叉排序树 Leetcode-35, 34, 33, 449, 315
#include <stdio.h>#include <vector>// //二分查找(递归)// bool binary_search(std::vector<int> &sort_array, int begin, int end ,int target){// if(begin > end){// ...
2019-09-15 00:30:00
86
转载 Day-05-二叉树与图 Leetcode-113, 236, 113, 199, 207
//预备知识:二叉树的构造#include <stdio.h>struct TreeNode { int val; TreeNode* left; TreeNode* right; TreeNode(int x) : val(x), left(NULL), right(NULL) {}};void preord...
2019-09-15 00:25:00
109
转载 Day-04-递归、回溯与分支 Leetcode-78, 90, 40, 22, 51, 315
//将链表中的节点push进vector#include <stdio.h>#include <vector>struct ListNode { int val; ListNode* next; ListNode(int x) : val(x), next(NULL) {}};void add_to_vector...
2019-09-15 00:19:00
101
转载 Day-03-贪心 Leetcode-445, 376, 402, 55, 45, 452 POJ-2431
例一:LeetCode445//已知一些孩子和一些糖果,每个孩子有需求因子g,每个糖果大小s//当某个糖果的大小s>=某个孩子的需求因子时,代表该糖果可以满足//该孩子,求使用这些糖果最多可以满足多少孩子。#include <stdio.h>#include <vector>#include <algorithm>cl...
2019-09-15 00:06:00
120
转载 Day-02-栈、队列、堆 Leetcode-225, 231, 155, 224, 215, 295 POJ-1363
例一:LeetCode225#include <iostream>#include <queue>using namespace std;class Mystack {public: Mystack() { } void push(int x) { queue<int>...
2019-09-15 00:02:00
138
转载 Day-01-链表 Leetcode-206, 92, 160, 141, 86, 138, 21, 23
例一:LeetCode206//已知链表头节点指针head,将链表逆序,不可申请额外空间#include <stdio.h>struct ListNode { int val; ListNode* next; ListNode(int x) :val(x), next(NULL) {}};class Solution {...
2019-09-14 23:49:00
130
转载 汇编十道小题
1、从键盘输入一个字符串(长度不超过30),统计字符串中非数字的个数,并将统计的结果显示在屏幕上,用EXE格式实现。data segment str db 30,?,30 dup(?);30是限制个数,?存储实际个数 count db 0data endscode segment assume cs:code,ds:data main proc farstart:...
2019-09-14 23:40:00
680
转载 Treap树模板hdu-4585
例题:hdu 4585Treap树是一种简单的平衡二叉搜索树。二叉搜索树的每一个节点都有一个键值,除此之外Treap树为每个节点人为添加了一个称之为优先级的权值。对于键值来说,这是一棵二叉搜索树,对于权值来说这是一个堆。1、Treap树的唯一性Treap树的重要特性:另每个节点的优先级互不相等,那么整棵树的形态时唯一的,和元素的插入顺序没有关系。2、Treap树的平衡问题...
2019-09-14 23:27:00
150
转载 并查集模板hdu-1213
例题:hdu 1213//#include <bits/stdc++.h>#include <iostream>#include <stack>#include <string>#include <queue>#include <stack>#include <set>#include ...
2019-09-14 23:22:00
116
转载 二分模板
二分模板二分模板一共有两个,分别适用于不同情况。算法思路:假设目标值在闭区间[l, r]中, 每次将区间长度缩小一半,当l = r时,我们就找到了目标值。模板一当我们将区间[l, r]划分成[l, mid]和[mid + 1, r]时,其更新操作是r = mid或者l = mid + 1;,计算mid时不需要加1。C++ 代码模板:int bsearch_1(int l, ...
2019-09-14 23:15:00
96
转载 冒泡排序模板
// 冒泡排序模板,升序// 数组从下标1开始存储// 存储n个数// 只有n < 10000时才能用冒泡排序,否则应使用其他排序方法 #include <bits/stdc++.h>using namespace std;int a[10000001]; #define swap(a, b){int temp = a; a = b; b = te...
2019-09-14 23:08:00
184
转载 Operating System 作业-01
简答题3.2、内核采取一些动作以便在两个进程之间进行切换,请描述一下。 总的来说,操作系统必须保存正在运行的进程的状态,恢复进程的状态。保存进程的状态主要包括CPU寄存器的值以及内存分配,上下文切换还必须执行一些确切体系结构的操作,包括刷新数据和指令缓存。 进程关联是由进程的PCB来表示的,它包括CPU寄存器的值和内存管理信息等。当发生上下文切换时,内核会将旧进程的关联状态保存...
2019-09-14 22:02:00
1817
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人