- 博客(13)
- 资源 (3)
- 收藏
- 关注
原创 1127 ZigZagging on a Tree (30分)
要点1.根据后序和中序建立树得会要点2.记录每层的元素得会,front 和last 还有 rear的关键点,即非递归求树高#include<iostream>#include<queue>#include<stack>using namespace std;int n,post[35],in[35];struct Node{ int dat...
2020-01-14 16:44:51 132
原创 1125 Chain the Ropes (25分)
Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments into loops and chain them into one piece, as shown by the figure. The resulting chai...
2020-01-14 19:08:29 137
原创 PAT 甲 1126 Eulerian Path (25分)
要点1:注意考察图的连通性,用dfs,看看一次dfs能否遍历所有的点,如果不联通,就不是欧拉图要点2:会出现所有的点都在边里,但还是不联通的情况,所以必须用dfs,不能直接看点有没有被输入过#include<iostream>#include<map>#include<vector>using namespace std;int n,m,cnt...
2020-01-14 18:25:30 147
原创 PAT 甲 1135 红黑二叉树
题目要点:解题的关键是理解题目所说的红黑的性质There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties: (1) Every node is either red or black....
2020-01-10 18:43:01 177
原创 PAT 甲 1136
知识点: 大整数加法,reverse 函数的应用要注意的点 就是输入的数本身是回文数的情况#include<iostream>#include<algorithm>using namespace std;bool isr(string s){ for(int i=0;s[i];++i){ if(s[i]!=s[s.length()-1-i]) retu...
2020-01-10 15:41:27 134
原创 PAT 甲级 1139
总结如果要在set或map 存结构体 就一定要重定义 "<"对于结构体数组进行排序,cmp函数是必须的格式化输出补零用%04d ,保留4位小数用%.4f当有例子过不去的时候 一定要仔细读题 把逻辑理顺题目看不懂的时候一定要仔细分析测试用例#include<iostream>#include<map>#include<vecto...
2020-01-09 17:42:27 133
原创 PAT 甲1140
#include<iostream>using namespace std;int d,n;string fun(string s){ int h[10]={0}; string head=""; for(int i=0;s[i];++i){ h[s[i]-'0']++; if(s[i]!=s[i+1]){ ...
2020-01-09 11:54:11 130
原创 PAT 甲级 1145 解题记录
//这题遇到了两个大问题//处理碰撞的函数搞错了//计算查找长度时,没有考虑 本来就没有尝试插入的情况,只考虑到插入但是失败的情况//对于探测失败 为什么到 Tsize,当j==Tsize时 j*j=Tsize*Tsize,//于是 (H(key)+j*j)%Tsize==H(key)即j=0 时的情况,即回到原来的地方了 于是当j==Tsize 查找失败 //(H(key)+j*j)...
2020-01-08 14:34:35 232
原创 PAT乙级 1029 旧键盘
#include<iostream>using namespace std;int main(){ string a,b; cin>>a>>b; string s=""; for(int i=0;a[i];){ if(a[i]!=b[i]||b[i]=='\0') { char temp=char(a[i]>='a'?a[i]-32...
2019-02-26 22:24:47 147
原创 PAT 1028 人口普查 (20 分)
将日期转化为天数简化了条件判断。测试用例全部通过,虽然没有仔细考虑闰年和大小月的问题。#include<iostream>#include<vector>#include<cstdlib>#include<algorithm>using namespace std;struct Person{ char name[6]; ...
2019-02-26 21:20:41 304
原创 Matlab蚁群算法解决TSP问题代码超详细注释
直接把建模作业贴上来了,代码是参考一个学长写的,图解的话百度文库里有好多不错的资料,配合这个代码应该可以很好的理解毕竟我也是小白 如果有错误欢迎指正:clc;clear all;t1=clock;%用于记录运行时间X=[114 50 99 30 60 26 29 7 53 40 102 3 32 12 100 38 5 2 91 5 46 105 95 94 34 116
2017-07-31 22:48:34 8499 4
转载 Matlab axis用法
转载地址http://blog.sina.com.cn/s/blog_b26a90750101kxdx.htmlaxis off;% 去掉坐标轴axistight;% 紧坐标轴axisequal;% 等比坐标轴axis([-0.1, 8.1, -1.1, 1.1]);% 坐标轴的显示范围% gca: gca, h=figure(...);set(gca,'XLim'
2017-07-31 18:50:13 51377
原创 正则表达式的小应用(按空白分割文本但是保留"\n")
正则表达式从一段文字中提取想要的东西:比如说从一篇英语阅读中提取除了空格以外的东西包括单词换行符标点下滑线:Small Schools Rising This year's list of the top 100 high schools shows that today, those with fewer students are flourishing. Fifty yea
2017-07-31 12:42:58 690
神经网络识别手写数字(含数据和代码,只要有matlab就可以运行)
2018-02-01
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人