题意:给两条直线,判断相交,重合或者平行 思路:判断重合可以用叉积,平行用斜率,其他情况即为相交。 求交点: 这里也用到叉积的原理。假设交点为p0(x0,y0)。则有: (p1-p0)X(p2-p0)=0 (p3-p0)X(p2-p0)=0 展开后即是 (y1-y2)x0+(x2-x1)y0+x1y ...
分类:
其他好文 时间:
2016-08-02 11:38:44
阅读次数:
181
就是HashMap吧 好吧,我写得太丑了 别人的方法:https://discuss.leetcode.com/topic/20314/accepted-java-o-n-solution-in-5-lines/2 实在是很好看= =……下次还是要看看别人写的 因为一共就26的字母,他建立了一个长度 ...
分类:
其他好文 时间:
2016-07-30 06:52:51
阅读次数:
117
#保留符合要求的N个条目
fromcollectionsimportdeque
defsearch(lines,pattern,history=5):
previous_lines=deque(maxlen=history)#队列
forliinlines:
ifpatterninli:
yieldli,previous_lines#找到pattern,并yield
previous_lines.append(li)#入队列
#Exampleuseomsfile
if_..
分类:
其他好文 时间:
2016-07-24 21:01:04
阅读次数:
241
一. glBegin(GL_LINES); glend(); 二.线带和线环 glBegin(GL_LINE_STRIP); glend(); glBegin(GL_LINE_LOOP); glend(); 三.设置直线宽度 glLineWidth(GLfloat width); 四.获得直线宽度范 ...
分类:
其他好文 时间:
2016-07-23 20:56:00
阅读次数:
133
把如下命令拷贝到一个文件中,并保存为bat后缀的文件;然后把这个bat文件保存到相应文件夹下。 @echo on color 2f mode con: cols=80 lines=25 @REM @echo 正在清理SVN文件,请稍候...... @rem 循环删除当前目录及子目录下所有的SVN文件 ...
分类:
其他好文 时间:
2016-07-22 23:11:47
阅读次数:
158
贴出 批处理 代码: @echo off & cls title The batch file is in order to locate specified row and column By Frank V1.1color 1fmode con cols=115 lines=25rem 设置变量 ...
分类:
其他好文 时间:
2016-07-22 19:02:00
阅读次数:
153
这是一个简单的小游戏,类型相当于amidar,不过也有1000行,手困眼花......UP\DOWN\LEFT\RIGHT控制,SPACE重新开始。 在TimerInit()函数中,QueryPerformanceFrequency()函数查询性能计数器的频率。QueryPerformanceCou ...
分类:
其他好文 时间:
2016-07-21 00:41:50
阅读次数:
231
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo ...
分类:
其他好文 时间:
2016-07-14 09:50:04
阅读次数:
119
原遍历数组NSArray * lines = ...for (NSString * line in lines) { // ...}for (int i = 0; i < lines.count; ++i) { NSString * s = [lines objectAtIndex:i]; ...} ...
分类:
编程语言 时间:
2016-07-13 10:27:04
阅读次数:
220