自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(33)
  • 问答 (2)
  • 收藏
  • 关注

原创 android学习笔记-MVP实例

最近在疯狂学习mvp架构,看了一堆博文也没整明白,最后还是谷歌的官方案例给整明白了,遂整理记录,有错误的地方,还请大神们指教。 mvp基本结构如图,view持有presenter,presenter持有view和model,presenter通过持有的model存取数据,通过持有的view获取view中的数据,或改变view的ui显示。可以看到view中有个set方法,主要是方便外部注入presenter实例,这里是通过presenter中持有的view来调用setpr...

2020-11-25 16:08:08 450 2

原创 android MVP笔记-view与model的解耦

众所周知,mvp中view和model通过presenter实现解耦。其中presenter中持有view和model的引用,view中持有presenter的引用,如图: 现在的问题是,View持有mPresenter引用需要指向Presenter,一个方法是在View中new一个Presenter,然而,new Presenter需要提供view和model作为初始参数,则View中代码为:mPresenter = new Presenter(this,new...

2020-11-21 23:56:51 514 3

原创 手写LRU(java版)

class LRU{ //链表节点,存键值对 private class Node{ int key; int val; Node next = null; Node(int key,int val){ this.key = key; this.val = val; } } //维护链表长度 private int length = 0; //表头 private Node list = new Node(0,0); //LRU最大长.

2020-10-25 20:15:37 1387

原创 Java手写快速排序 无需交换版本

public class QuickSort { public static void sort(int[] a) { quickSort(a,0,a.length-1); //递归包裹,这样对外可以只传一个参数 } private static void quickSort(int[] a,int i,int j) { int partition = partition(a,i,j); if(i!=partition-1&&i!=partition) { qui.

2020-08-20 18:40:20 163

原创 如何做一个手写字符判别系统?(问题篇)

简介 手写字符识别问题大家一定不陌生,例如mnist手写数字识别,学深度学习的时候第一个实例就是它,输入的是手写数字的图片,输出的就是对应的数字。凭借着海量的训练数据以及复杂的网络结构,这个问题可以得到很好的结果。 那么什么是手写字符判别呢?其实我也不知道,因为这个名字实我自己瞎编的(逃。。。好吧,其实问题是这样的,现在我有一个系统,输入是用户的手写数据,输出的是判断结果,即输入是不是系统想要的那个字符。这有什么用呢?我觉得至少可以用在教育业务上,比如下面这个是我目前正在...

2020-08-10 20:42:42 296

原创 android.view.WindowLeaked onKeyDown

做android开发时,想让活动返回时能弹出一个对话框来确认,网上搜了一下使用的是重写onKeyDown()方法,在模拟器上跑没问题,但一到手机上就出现对话框闪一下就退的问题。看了log是android.view.WindowLeaked onKeyDown异常,好吧,又上网查了半天,都是说活动finish时对话框没关闭啥的,但这解释不了为什么模拟器上能跑手机上不能跑啊。 最后问题锁定到了onKeyDown()上,此方法兼容Android 1.0到Android 2.1,把onKeyD...

2020-05-21 21:06:52 109

原创 1086. Tree Traversals Again (25) PAT甲级刷题

An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stac...

2018-03-17 10:55:29 200

原创 1127. ZigZagging on a Tree (30) PAT甲级刷题

1127. ZigZagging on a Tree (30)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueSuppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determin...

2018-03-11 00:19:59 129

原创 1030. Travel Plan (30) PAT甲级刷题

1030. Travel Plan (30)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you ...

2018-03-08 23:03:44 162

原创 1053. Path of Equal Weight (30) PAT甲级刷题

Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti. The weight of a path from R to L is defined to be the sum of the weights of all the nodes along the path from R to...

2018-02-28 01:00:45 202 3

原创 1034. Head of a Gang (30) PAT甲级刷题

题目描述One way that the police finds the head of a gang is to check people'sphone calls. If there is a phone call between A and B, we say that Aand B is related. The weight of a relation is defined t...

2018-02-26 02:52:07 290

原创 1047. Student List for Course (25) PAT甲级刷题

题目描述Zhejiang University has 40000 students and provides 2500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.输入描述:E...

2018-02-24 23:24:56 128

原创 1032.Is It a Binary Search Tree (25) PAT甲级刷题

题目描述A Binary Search Tree (BST) is recursively defined as a binary tree whichhas the following properties:The left subtree of a node contains only nodes with keys less than the node's key. The right...

2018-02-23 17:00:41 91

原创 1041. Be Unique (20) PAT甲级刷题

题目描述Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1, 104]. The first one who be...

2018-02-22 23:05:13 215

原创 1042. Shuffling Machine (20) PAT甲级刷题

题目描述Shuffling is a procedure used to randomize a deck of playing cards.Because standard shuffling techniques are seen as weak, and in order toavoid "inside jobs" where employees collaborate with gam...

2018-02-22 22:42:10 173

原创 1051.Pop Sequence (25) PAT甲级刷题

题目描述Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequenc...

2018-02-22 16:20:22 201

原创 1102. Invert a Binary Tree (25) PAT甲级刷题

The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck off.Now it's your turn to prove...

2018-02-16 23:51:59 132

原创 1099. Build A Binary Search Tree (30) PAT甲级刷题

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key.The right subtre...

2018-02-12 21:40:56 143

原创 1029. Median (25) PAT甲级刷题

Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1={11, 12, 13, 14} is 12, and the median of S2={9, 10, 15, 16, 17} is 15. The...

2018-02-09 15:39:11 168

原创 1035. Password (20) PAT甲级刷题

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L ...

2018-02-09 15:03:30 126

原创 1027. Colors in Mars (20)

People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 dig...

2018-02-09 14:36:17 82

原创 1015. Reversible Primes (20) PAT甲级刷题

A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a pr...

2018-02-08 14:12:27 92

原创 1014. Waiting in Line (30) PAT甲级刷题

Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in line are:The space i...

2018-02-08 01:03:42 153

原创 1013. Battle Over Cities (25)

It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we nee...

2018-02-07 22:17:37 70

原创 1012. The Best Rank (25) PAT甲级刷题

To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algebra), and E - Eng

2018-02-07 20:30:15 103

原创 1009. Product of Polynomials (25)

This time, you are supposed to find A*B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the inf

2018-02-06 19:53:29 100

原创 1008. Elevator (20) PAT甲级刷题

The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 sec

2018-02-06 04:54:47 148

原创 1006. Sign In and Sign Out (25) PAT甲级刷题

At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, you

2018-02-06 02:29:51 208

原创 1005. Spell It Right (20) PAT甲级刷题

Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input file contains one test case.

2018-02-06 01:26:34 83

原创 1004. Counting Leaves (30) PAT甲级刷题

A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.InputEach input file contains one test case. Each case starts with

2018-02-05 22:53:05 90

原创 1003. Emergency (25) PAT甲级刷题

As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the l

2018-02-05 20:31:19 103

原创 1002. A+B for Polynomials (25) PAT甲级刷题

This time, you are supposed to find A+B where A and B are two polynomials.InputEach input file contains one test case. Each case occupies 2 lines, and each line contains the information of a p

2018-02-04 20:33:52 141

原创 1001. A+B Format (20)-PAT甲级刷题

Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).InputEach input file cont

2018-02-04 19:02:13 126

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除