随笔分类 - 机试真题
摘要:裸的弗洛伊德算法,题目中指定,再阐述一下思想; 弗洛伊德思想: 对于n个结点,如果该节点当其他任意两个结点i,j的中继,可以缩短i和j之间的距离,则进行更新; 采用三个循环更新,复杂度为O(n^3); #include<iostream> #include<vector> #include<stri
阅读全文
摘要:两种主流思想: 1.直接全部扫描棋盘,按四个方向逐个遍历,不仅麻烦而且很傻; 2.每落一个子,直接对该子进行四个方向判定,且判定的时可以一个方向左右加和; #include<iostream> #include<vector> #include<string> using namespace std
阅读全文
摘要:之前总结过,大数问题,取模就是取商取余数; #include<iostream> #include<stdlib.h> #include<string> using namespace std; string devide(int& r, string s, int n) { string ss =
阅读全文
摘要:模拟大致的分母相加减的问题; 利用最大公约数和最小公倍数可以解决; 对于不同分母,求最小公倍数; 加和化简之后,采用最大公约数进行分子分母同除计算; 最小公倍数和最大公约数相关的问题之前总结过; #include<iostream> #include<string> #include<vector>
阅读全文
摘要:老生常谈的问题,留商取余; #include<iostream> #include<string> using namespace std; int n; string charge(int n) { string s=""; while (n != 0) { int r = n % 8; s =
阅读全文
摘要:没啥难度,还是难以判断测试用例的问题,也就是k是否大于10,否则就会采用字符串进行判断; #include<iostream> #include<vector> #include<queue> #include<string> using namespace std; int n, k; struc
阅读全文
摘要:实际是匹配子串问题,使用STL中的string::find()和string::erase()即可,自己还动手写了一遍自己的; #include<iostream> #include<stdio.h> #include<string> using namespace std; string s; s
阅读全文
摘要:水题; #include<iostream> #include<vector> using namespace std; const int maxn = 100; int m, n, p; int m1[maxn][maxn], m2[maxn][maxn],m3[maxn][maxn]; int
阅读全文
摘要:对一个非方阵矩阵转置; 注意转置后列变成行,行变成列; #include<iostream> #include<stdlib.h> using namespace std; const int maxn = 500; int a[maxn][maxn]; int m, n; int main() {
阅读全文
摘要:题目:一个文件中的一串数字,用逗号分割,位23.34,4242.42,343.......,要求读出并排序; 之前总结过,还是要多看看注意一下; https://www.cnblogs.com/songlinxuan/p/12370059.html 代码: #include<iostream> #i
阅读全文
摘要:问题:座位排序,对于7个人A,B,、、、G,输入7行,每一行比如 A B 6,G C -2这种表示A在B前面6排,G在C前面-2排(在C后面2排),求出这7个人从前到后顺序,最前面的是第一排,输出结果 目前没看出这个要用什么数据结构在做,个人觉得直接设定一个基准坐标,循环计算各个点的数轴位置即可;
阅读全文
摘要:坑挺多的,没有现成的测试用例,不知道包含不包含JS,或者特殊标签的问题; 所以一切按照规格HTML来进行; 例如百度的简单网页:https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_935486
阅读全文

浙公网安备 33010602011771号