链表判断是否有环与判断环入口

Detect cycle in a linked list. A singly-linked data structure is a data structure made up of nodes where each node has a pointer to the next node (or a pointer to null). Suppose that you have a pointer to the first node of a singly-linked list data structure:
Determine whether a singly-linked data structure contains a cycle. You may use only two pointers into the list (and no other variables). The running time of your algorithm should be linear in the number of nodes in the data structure.
If a singly-linked data structure contains a cycle, determine the first node that participates in the cycle. you may use only a constant number of pointers into the list (and no other variables). The running time of your algorithm should be linear in the number of nodes in the data structure.
You may not modify the structure of the linked list.

1)判断有没有环用在链表头同时放一个“慢”指针(一次走一步),一个“快”指针(一次走两步),然后判断能否相遇。

2)相遇位置时,“快”指针比“慢”指针多走了一个环的位置。

在相遇位置和链表头同时放置两个“慢”指针,两个“慢”指针相遇位置就是环入口。

iOS产生随机字符串

1
2
3
char data[NUMBER_OF_CHARS];
for (int x=0;x<NUMBER_OF_CHARS;data[x++] = (char)('A' + (arc4random_uniform(26))));
return [[NSString alloc] initWithBytes:data length:NUMBER_OF_CHARS encoding:NSUTF8StringEncoding];

用pacman 从archlinux 中获取程序源代码

  1. pacman -S abs
  1. pacman -S base-devel

  2. As root, edit /etc/abs.conf to include your desired repositories: vim /etc/abs.conf. Remove the ! in front of the appropriate repositories, for example: REPOS=(core extra community !testing)

4.Download the Arch Build System(ABS) tree. As root, run:abs. Your ABS tree is now created under /var/abs. The above step is done once for all(run abs from time to time to update the source tree though). Next,

5.say if you want the source code of the Linux command find
1)find out which package the command find belongs to: pacman -Qo echo which find. The result is “usr/bin/find is owned by findutils 4.4.2-3”.

cp -r /var/abs/core/findutils /home/yourname/a_directory

cd /home/yourname/a_diretory
makepkg

Now you have your source code.

Unix philosophy ---取自The art of unix programming

  1. Rule of Modularity: Write simple parts connected by clean interfaces.
  1. Rule of Clarity: Clarity is better than cleverness.
  1. Rule of Composition: Design programs to be connected to other programs.
  1. Rule of Separation: Separate policy from mechanism; separate interfaces from engines.
  1. Rule of Simplicity: Design for simplicity; add complexity only where you must.
  1. Rule of Parsimony: Write a big program only when it is clear by demonstration that nothing
    else will do.
  1. Rule of Transparency: Design for visibility to make inspection and debugging easier.
  1. Rule of Robustness: Robustness is the child of transparency and simplicity.
  1. Rule of Representation: Fold knowledge into data so program logic can be stupid and robust.
  1. Rule of Least Surprise: In interface design, always do the least surprising thing.
  1. Rule of Silence: When a program has nothing surprising to say, it should say nothing.
  1. Rule of Repair: When you must fail, fail noisily and as soon as possible.
  1. Rule of Economy: Programmer time is expensive; conserve it in preference to machine time.
  1. Rule of Generation: Avoid hand-hacking; write programs to write programs when you can.
  1. Rule of Optimization: Prototype before polishing. Get it working before you optimize it.
  1. Rule of Diversity: Distrust all claims for “one true way”.
  1. Rule of Extensibility: Design for the future, because it will be here sooner than you think.

phonegap+jquery iOS画面跳转闪烁问题解决

在html所用到的css加入如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

.ui-mobile, .ui-mobile .ui-page, .ui-mobile [data-role="page"],
.ui-mobile [data-role="dialog"], .ui-page, .ui-mobile .ui-page-active {
overflow: hidden;
-webkit-backface-visibility: hidden;
}
.ui-header {
position: fixed;
z-index:10;
top:0;
width:100%;
padding:0 0;

}
.ui-content {
padding-top: 57px;
padding-bottom: 54px;
overflow: auto;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.ui-footer {
position: fixed;
z-index:10;
bottom:0;
width:100%;
}

并将header footer 的 data-position=”fixed”去掉