- 博客(113)
- 收藏
- 关注
原创 1140 Look-and-say Sequence (20 分)
#include<string>#include<stdio.h>#include<stdlib.h>#include<string.h>#include<vector>#include<unordered_map>#include<algorithm>#include<iostream>using namespace std;//3:23string str;int N;int main
2022-03-03 16:05:09
153
原创 1148 Werewolf - Simple Version (20 分)
关键一步是找出了狼人就找到了谁撒谎.哎,离考试只有5天了,怎么复习!心神不宁.
2022-02-27 23:16:57
179
原创 大数加减法
加法:string add(string s1, string s2){ char flag = 0;//表示进位 string ans; while (s1.length() && s2.length()) { char num = (s1.back()) + (s2.back()) - 2 * '0' + flag; if (num < 10) { ans = char(num + '0') + ans; flag = 0; } else
2022-02-26 17:13:37
146
原创 1112 Stucked Keyboard (20 分)
#include <iostream>#include <vector>#include <unordered_map>using namespace std;int K;string str;vector<char>ans1;vector<char>ansf;unordered_map<char, int>mp;unordered_map<char, int>mpnot;int main(){ s
2022-02-25 10:14:44
429
原创 PAT 1131. Subway Map (30) -甲级
#include <iostream>#include <vector>#include <unordered_map>using namespace std;int getransfer();void dfs(int a);int N;vector<vector<int>>G(10000);unordered_map<int, int>mp;bool visited[10000];int start, destin
2022-02-24 21:52:45
162
原创 1159 Structure of a Binary Tree (30 分)
收获:深度从上往下计数,根节点深度为1;高度从下往上计数sscanf的使用#include<stdio.h>#include<stdlib.h>#include<string.h>#include<string>#include<vector>#include<iostream>#include<algorithm>#include<math.h>#include<unordered_
2022-02-23 21:07:53
132
原创 关于进制转换
我不太熟悉,做起来蛮生硬的 int a, b, c, d;//17a=1b;24b=1c;67c=1d; a = 15; b = 23; c = 56; d = 3; int sum = a + b * 17 + c * 24 * 17 + d * 67 * 24 * 17; a = sum % 17; b = sum % (24 * 17) / 17; c = sum % (67 * 24 * 17) / (24 * 17); d = sum / (67 * 24 * 17); print
2022-02-22 13:13:18
92
原创 1114 Family Property (25 分)
并查集收获:如果ufs[root]是-1*集合内元素数目,则合并时应该判断一下是不是同一个根节点,否则会发生错误如果要ufs[node]为跟,则需要再find一遍
2022-02-21 14:29:57
107
原创 优先队列使用
#include <stdio.h>#include <string.h>#include<iostream>#include<vector>#include<string>#include<unordered_map>#include<algorithm>#include<math.h>#include<queue>#define infinity 100000000using
2022-02-20 09:03:53
44
原创 基础实验6-2.1 列出连通集 (25 分)
BFS放进去后visited[p]=true,如果取出来才visited[p]=true,那可能重复打印
2022-02-09 16:47:46
308
原创 题出错点记录
2022 2/4案例5-1.3 整型关键字的散列映射 (25 分)变量明明不好,导致错用,最后一个测试点深陷在循环中了案例5-1.4 字符串关键字的散列映射 (25 分)Hash函数写错,导致最后一个测试点出错(奇迹的是其它测试点都对了)...
2022-02-04 16:49:09
145
原创 习题5.13 词频统计 (30 分)
#include <stdio.h>#include <string.h>#include<iostream>#include<vector>#include<string>#include<unordered_map>#include<algorithm>using namespace std;bool JudgeChar(char c);unordered_map<string, int>H
2022-02-03 17:07:51
462
原创 线性探测法收获
Position Find(HashTable H, ElementType Key){ Position P = Hash(Key, H->TableSize);/*位置*/ int i = 0; while (H->Cells[P].Data != Key && H->Cells[P].Info != Empty)/*有空的或者是相等*/ { P = (P + 1) % H->TableSize;
2022-02-03 11:39:12
239
原创 7-21 求前缀表达式的值 (25 分)
自己写的程序的收获:#define _CRT_SECURE_NO_WARNINGS#include <stdlib.h>#include<stack>#include<iostream>#include<string>using namespace std;bool judgeOperator(char c);string Operate(char c, string s1, string s2);/*疑惑问题:怎么区分+-*和数字呢*/
2022-01-30 21:19:21
788
原创 地址映射与共享
#include <linux/mm.h>/*for get_free_page,put_page*/#include<linux/sched.h>/*for pointer current,get_base*/#include<linux/kernel.h>/*上次没有这个出毛病*/unsigned long RAM[20];/*储存物理地址*/int sys_shmget(int key){ if(!RAM[key])/*如果没有分配物理地址*/ {
2022-01-25 16:26:40
432
原创 信号量的实现和应用
此实验最难的地方:读了文件的数字以后怎么记录哪些读过参考我在内核态加了一个consumption变量和两个用于读/写consumption的系统调用.遇到的坑:sem.h make以后复制才行不能在用户态下访问内核态的内存.,所以我一开始不知道怎么停止消费者进程,比较有趣的地方:把把int型变量的地址强行转化为char*类型,对其每一个字节进行操作.进程休眠和唤醒队列我用的是显式队列主程序#define __LIBRARY__#include <stdio.h>/*sprintf
2022-01-20 21:01:45
341
原创 寒假十天反思
最近状态差强人意,操作系统实验收获蛮多.但是容易分神,特别是那个股票,我真的不应该经常关注,没意义.可能前一天赚了好多钱第二天赔了,也可能当天赔了.患得患失,只有学到的知识和思想才是自己的财富....
2022-01-18 15:11:05
189
原创 基于内核栈切换的进程切换
记载我的一些收获:1switch_to是汇编,c语言调用时,可以在其源文件上加.globl switch_to2first_return_from_kernel是汇编,使用extern void first_return_from_kernel(void)后,将first_return_from_kernel放入栈中,ret后即可执行3网上代码有一个错误,但是我运行了没出错,在这里指出:应该等于(33*16)+4,因为(让我对c语言struct这一数据结构更加清晰)这个一个是16字节4当我改
2022-01-17 14:25:22
496
原创 进程运行轨迹的跟踪与统计
在这里我记录一下process.c文件,别忘了如果在printk里面写了fprintk,需要再在kernel.h头文件里加上fprintk的函数原型#include <stdio.h>#include <unistd.h>#include <time.h>#include <sys/times.h>#include <sys/wait.h>#define HZ 100void cpuio_bound(int last, int cp
2022-01-14 13:32:14
265
原创 practice is the father of learning
我高中时犯下的错误,看题看知识点做题且很少。这样只是浅显的记住了并没有深入理解。所以不能只看不练。repetition is the motherof learning
2022-01-07 15:40:52
172
原创 反思二获得信息会令人上瘾
我相信获得大量冗余且浅显信息会钝化大脑。且大脑对此类信息极易上瘾。譬如抖音,b站,知乎。看了只会获得短暂即时快感。应减少。
2022-01-07 15:36:55
260
原创 寒假前反思
最近浮躁,非常浮躁,1闲的没事就看股票。为什么?因为股票可以带来即时快感,像游戏一样。2不喜欢看“没用的东西”,然而挑挑选选也浪费了时间,“没用的东西只是现在没用,以后可能有用,所以应该看看”3不会享乐,不知道休息时干什么。我觉得可以弹弹吉他,听听小说,或者录一些视频之类的。总之,既要学会工作,也要学会休息。切忌即时满足。希望度过一个快乐的寒假。最近水平真的提升了,上学期p值看不懂,这学期看了十分钟竟然看懂了。我把它归功于这学期学习数学竞赛,计组,汇编的结果。记忆力,理解力提升明显。保护眼睛,不纠缠,洒脱点
2022-01-07 15:28:15
1971
原创 PAT1003Emergency
#include<stdio.h>#include<stdlib.h>#include<vector>#include<queue>#include<algorithm>#include<unordered_map>#include<iostream>#include<string>#define INFINITY 9999999using namespace std;int N, M, C1
2021-12-23 15:57:47
500
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人