CS-Notes/notes/编写可读代码的艺术.md

343 lines
8.0 KiB
Markdown
Raw Normal View History

2018-02-22 01:06:40 +08:00
<!-- GFM-TOC -->
2018-02-22 14:47:54 +08:00
* [<EFBFBD><EFBFBD> 1 <20><> <20>ɶ<EFBFBD><C9B6>Ե<EFBFBD><D4B5><EFBFBD>Ҫ<EFBFBD><D2AA>](#<23><>-1-<2D><>-<2D>ɶ<EFBFBD><C9B6>Ե<EFBFBD><D4B5><EFBFBD>Ҫ<EFBFBD><D2AA>)
* [<EFBFBD><EFBFBD> 2 <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBBAAC>](#<23><>-2-<2D><>-<2D><><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBBAAC>)
* [<EFBFBD><EFBFBD> 3 <20><> <20><><EFBFBD>ֲ<EFBFBD><D6B2>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#<23><>-3-<2D><>-<2D><><EFBFBD>ֲ<EFBFBD><D6B2>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [<EFBFBD><EFBFBD> 4 <20><> <20><><EFBFBD>õĴ<C3B5><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#<23><>-4-<2D><>-<2D><><EFBFBD>õĴ<C3B5><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [<EFBFBD><EFBFBD> 5 <20><> <20><>дע<D0B4><D7A2>](#<23><>-5-<2D><>-<2D><>дע<D0B4><D7A2>)
* [<EFBFBD><EFBFBD> 6 <20><> <20><><EFBFBD>α<EFBFBD>дע<D0B4><D7A2>](#<23><>-6-<2D><>-<2D><><EFBFBD>α<EFBFBD>дע<D0B4><D7A2>)
* [<EFBFBD><EFBFBD> 7 <20><> <20><><EFBFBD>߿<EFBFBD><DFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀɶ<C4BF><C9B6><EFBFBD>](#<23><>-7-<2D><>-<2D><><EFBFBD>߿<EFBFBD><DFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀɶ<C4BF><C9B6><EFBFBD>)
* [<EFBFBD><EFBFBD> 8 <20><> <20><><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD><EFBFBD>ʽ](#<23><>-8-<2D><>-<2D><><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD><EFBFBD>ʽ)
* [<EFBFBD><EFBFBD> 9 <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD>](#<23><>-9-<2D><>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD>)
* [<EFBFBD><EFBFBD> 10 <20><> <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>](#<23><>-10-<2D><>-<2D><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>)
* [<EFBFBD><EFBFBD> 11 <20><> һ<><D2BB>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>](#<23><>-11-<2D><>-һ<><D2BB>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>)
* [<EFBFBD><EFBFBD> 12 <20><> <20><><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>](#<23><>-12-<2D><>-<2D><><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* [<EFBFBD><EFBFBD> 13 <20><> <20><><EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD><EFBFBD><EFBFBD>](#<23><>-13-<2D><>-<2D><><EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD><EFBFBD><EFBFBD>)
2018-02-22 01:06:40 +08:00
<!-- GFM-TOC -->
2018-02-22 14:47:54 +08:00
# <20><> 1 <20><> <20>ɶ<EFBFBD><C9B6>Ե<EFBFBD><D4B5><EFBFBD>Ҫ<EFBFBD><D2AA>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>кܴ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Ķ<EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߱<EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD>ʡ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>Ը<EFBFBD><EFBFBD>ȥ<EFBFBD>޸<EFBFBD><EFBFBD>ⲿ<EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ġ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ֻ<EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>Ч<EFBFBD>ʲſ<EFBFBD><EFBFBD>Է<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>һλ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><> 2 <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBBAAC>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
һЩ<EFBFBD>Ƚ<EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD>ʣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
| <20><><EFBFBD><EFBFBD> | <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> |
2018-02-22 01:06:40 +08:00
| --- | --- |
2018-02-22 14:47:54 +08:00
| send | deliver<65><72>dispatch<63><68>announce<63><65>distribute<74><65>route |
| find | search<63><68>extract<63><74>locate<74><65>recover |
| start| launch<63><68>create<74><65>begin<69><6E>open|
|make|create<74><65>set up<75><70>build<6C><64>generate<74><65>compose<73><65>add<64><64>new|
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ʹ<EFBFBD><EFBFBD> i<><69>j<EFBFBD><6A>k <20><>Ϊѭ<CEAA><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǻõģ<C3B5>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӹ<EFBFBD><D3B8>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD> user_i<5F><69>member_i<5F><69><EFBFBD><EFBFBD>Ϊѭ<CEAA><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><E0A3AC><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿɶ<D6BF><C9B6>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴʵ<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֳ<EFBFBD><EFBFBD>̵<EFBFBD>׼<EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><> 3 <20><> <20><><EFBFBD>ֲ<EFBFBD><D6B2>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ˼<EFBFBD><EFBFBD>һ<EFBFBD>±<EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>кν<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD> min<69><6E>max <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><CEA7>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD> first<73><74>last <20><>ʾ<EFBFBD><CABE><EFBFBD>ʿռ<CABF><D5BC>İ<EFBFBD><C4B0><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><CEA7>begin<69><6E>end <20><>ʾ<EFBFBD><CABE><EFBFBD>ʿռ<CABF><D5BC><EFBFBD><EFBFBD>ų<EFBFBD><C5B3><EFBFBD>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD> end <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/26772ecc-a3e3-4ab7-a46f-8b4656990c27.jpg)
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> is<69><73>can<61><6E>should<6C><64>has <20><>ǰ׺<C7B0><D7BA>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><> 4 <20><> <20><><EFBFBD>õĴ<C3B5><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>ʵ<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD>к<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ͣ<EFBFBD>
2018-02-22 01:06:40 +08:00
```
2018-02-22 14:47:54 +08:00
int a = 1; // ע<><D7A2>
int b = 11; // ע<><D7A2>
int c = 111; // ע<><D7A2>
2018-02-22 01:06:40 +08:00
```
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> html <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD>ĸ<EFBFBD>ֵӦ<D6B5>úͱ<C3BA><CDB1><EFBFBD><EFBFBD><EFBFBD> html <20>е<EFBFBD>˳<EFBFBD><CBB3>һ<EFBFBD>£<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>صĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֯<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><> 5 <20><> <20><>дע<D0B4><D7A2>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD>ע<EFBFBD>⵽ע<EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>û̫<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD>ͻ<EFBFBD><EFBFBD>˷Ѵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫдע<EFBFBD>ͣ<EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҪΪÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD>򵥵<EFBFBD> getter <20><> setter <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>Щ<EFBFBD><D0A9><EFBFBD><EFBFBD>дע<D0B4>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6>Ը<EFBFBD><D4B8>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ע<EFBFBD>;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD>дע<EFBFBD>͡<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD>߸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD> TODO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
| <20><><EFBFBD><EFBFBD> | <20>÷<EFBFBD> |
2018-02-22 01:06:40 +08:00
|---|---|
2018-02-22 14:47:54 +08:00
|TODO| <20><><EFBFBD><EFBFBD> |
|FIXME| <20><><EFBFBD>޸<EFBFBD> |
|HACH| <20>ֲڵĽ<DAB5><C4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> |
|XXX| Σ<>գ<EFBFBD><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD> |
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><> 6 <20><> <20><><EFBFBD>α<EFBFBD>дע<D0B4><D7A2>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD>
2018-02-22 01:06:40 +08:00
```
// The first String is student's name
// The Second Integer is student's score
Map<String, Integer> scoreMap = new HashMap<>();
```
```
// Student' name -> Student's score
Map<String, Integer> scoreMap = new HashMap<>();
```
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```
//...
// Example: add(1, 2), return 3
int add(int x, int y) {
return x + y;
}
```
2018-02-22 14:47:54 +08:00
<EFBFBD>ںܸ<EFBFBD><EFBFBD>ӵĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>
2018-02-22 01:06:40 +08:00
```
int a = 1;
int b = 2;
int num = add(\* x = *\ a, \* y = *\ b);
```
2018-02-22 14:47:54 +08:00
ʹ<EFBFBD><EFBFBD>רҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵĽ<EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><> 7 <20><> <20><><EFBFBD>߿<EFBFBD><DFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀɶ<C4BF><C9B6><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD>dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```
if(len < 10)
if(10 > len)
```
2018-02-22 14:47:54 +08:00
if / else <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD> <20>ؼ<EFBFBD><D8BC>߼<EFBFBD><DFBC><EFBFBD><EFBFBD>ۣ<EFBFBD><DBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD>
2018-02-22 01:06:40 +08:00
```
if(a == b) {
2018-02-22 14:47:54 +08:00
// <20><><EFBFBD>߼<EFBFBD>
2018-02-22 01:06:40 +08:00
} else{
2018-02-22 14:47:54 +08:00
// <20><><EFBFBD>߼<EFBFBD>
2018-02-22 01:06:40 +08:00
}
```
2018-02-22 14:47:54 +08:00
ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><EFBFBD>򵥵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> ? : <20><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD><D5A3><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ò<EFBFBD><C3B2>ֳ<EFBFBD> if / else<73><65>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
do / while <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><DABA><EFBFBD><E6A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>һЩ<D2BB>Ի<EFBFBD><D4BB>ĵط<C4B5><D8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> while <20><><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> goto Ŀ<><EFBFBD><EAA3AC>ô goto <20><><EFBFBD>һ<EFBFBD><D2BB>ܽ<EFBFBD><DCBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD>ǹ<EFBFBD><C7B9>ڸ<EFBFBD><DAB8>ӵ<EFBFBD> goto <20><><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD><EFBFBD>ر<EFBFBD><D8B1>Ӧ<EEA3AC>ñ<EFBFBD><C3B1><EFBFBD>ʹ<EFBFBD><CAB9> goto<74><6F>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>Ƕ<EFBFBD>׵<EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD>һЩ return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD><DCBC><EFBFBD>Ƕ<EFBFBD>׵IJ<D7B5><C4B2><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><> 8 <20><> <20><><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD><EFBFBD>ʽ
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD>Ŀɶ<EFBFBD><EFBFBD>Ժܲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```
if line.split(':')[0].strip() == "root":
...
```
```
username = line.split(':')[0].strip()
if username == "root":
...
```
2018-02-22 14:47:54 +08:00
ʹ<EFBFBD><EFBFBD>Ħ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<EFBFBD>߼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```
if(!a && !b) {
...
}
```
```
if(a || b) {
...
}
```
2018-02-22 14:47:54 +08:00
# <20><> 9 <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD> break <20><><EFBFBD><EFBFBD> return <20><><EFBFBD>Լ<EFBFBD><D4BC>ٿ<EFBFBD><D9BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>á<EFBFBD>
2018-02-22 01:06:40 +08:00
```
boolean done = false;
while(/* condition */ && !done) {
...
if(...) {
done = true;
continue;
}
}
```
```
while(/* condition */) {
...
if(...) {
break;
}
}
```
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԽС<EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD>׶<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õĵط<EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
JavaScript <20><><EFBFBD><EFBFBD><EFBFBD>ñհ<C3B1><D5B0><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><C2B4><EFBFBD><EFBFBD><EFBFBD> submit_form <20>Ǻ<EFBFBD><C7BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>submitted <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƺ<EFBFBD><C6BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1BDBB><EFBFBD>Ρ<EFBFBD><CEA1><EFBFBD>һ<EFBFBD><D2BB>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD> submitted <20><>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD>ʵ<EFBFBD>ְ<EFBFBD> submitted <20>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><CEA7>
2018-02-22 01:06:40 +08:00
```
submitted = false;
var submit_form = function(form_name) {
if(submitted) {
return;
}
submitted = true;
};
```
```
var submit_form = (function() {
var submitted = false;
return function(form_name) {
if(submitted) {
return;
}
submitted = true;
}
2018-02-22 14:47:54 +08:00
}()); // () ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>
2018-02-22 01:06:40 +08:00
```
2018-02-22 14:47:54 +08:00
JavaScript <20><>û<EFBFBD><C3BB><EFBFBD><EFBFBD> var <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> var <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
**ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>**
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΣ<EFBFBD>
2018-02-22 01:06:40 +08:00
```
<input type = "text" id = "input1" value = "a">
<input type = "text" id = "input2" value = "b">
<input type = "text" id = "input3" value = "">
<input type = "text" id = "input4" value = "d">
```
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD> input <20>ֶ<EFBFBD><D6B6>У<EFBFBD><D0A3><EFBFBD>ʼʵ<CABC><CAB5><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
2018-02-22 01:06:40 +08:00
```
var setFirstEmptyInput = function(new_alue) {
var found = false;
var i = 1;
var elem = document.getElementById('input' + i);
while(elem != null) {
if(elem.value === '') {
found = true;
break;
}
i++;
elem = document.getElementById('input' + i);
}
if(found) elem.value = new_value;
return elem;
}
```
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
- found <20><><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>
- elem <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> for ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> while ѭ<><D1AD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```
var setFirstEmptyInput = function(new_value) {
for(var i = 1; true; i++) {
var elem = document.getElementById('input' + i);
if(elem === null) {
return null;
}
if(elem.value === '') {
elem.value = new_value;
return elem;
}
}
};
```
2018-02-22 14:47:54 +08:00
# <20><> 10 <20><> <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD>ǰѴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֳ<EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٰ<EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ż<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ߲<EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>꣬Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԵĴ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
```
int findClostElement(int[] arr) {
int clostIdx;
int clostDist = Interger.MAX_VALUE;
for(int i = 0; i < arr.length; i++) {
int x = ...;
int y = ...;
int z = ...;
int value = x * y * z;
int dist = Math.sqrt(Math.pow(value, 2), Math.pow(arr[i], 2));
if(dist < clostDist) {
clostIdx = i;
clostDist = value;
}
}
return clostIdx;
}
```
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD>ֲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD>߲<EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><EFBFBD>԰<EFBFBD><EFBFBD>ⲿ<EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺô<EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD>ԡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ġ<EFBFBD>
2018-02-22 01:06:40 +08:00
```
public int findClostElement(int[] arr) {
int clostIdx;
int clostDist = Interger.MAX_VALUE;
for(int i = 0; i < arr.length; i++) {
int dist = computDist(arr, i);
if(dist < clostDist) {
clostIdx = i;
clostDist = value;
}
}
return clostIdx;
}
```
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD>Խ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫȥ<EFBFBD>˽<EFBFBD>ijһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD>ڶ<EFBFBD><EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǻõġ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡҲ<EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><> 11 <20><> һ<><D2BB>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
ֻ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>µĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><EFBFBD>г<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>񣻰<EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD>ͬ<EFBFBD>Ķ<EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><> 12 <20><> <20><><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>α<EFBFBD><EFBFBD><EFBFBD>룬Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
# <20><> 13 <20><> <20><><EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD><EFBFBD><EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̻<EFBFBD><EFBFBD>кܶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õġ<EFBFBD>
2018-02-22 01:06:40 +08:00
2018-02-22 14:47:54 +08:00
<EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD>׼<EFBFBD><EFBFBD>ʵ<EFBFBD>֡<EFBFBD>