锘??xml version="1.0" encoding="utf-8" standalone="yes"?>999久久久国产精品,99久久国产精品免费一区二区,国产亚洲精久久久久久无码AVhttp://www.shnenglu.com/unixfy/just do itzh-cnFri, 09 May 2025 00:22:50 GMTFri, 09 May 2025 00:22:50 GMT60鍗氬閲嶅畾鍚戣嚦 http://www.cnblogs.com/unixfyhttp://www.shnenglu.com/unixfy/archive/2013/09/14/203237.htmlunixfyunixfySat, 14 Sep 2013 15:49:00 GMThttp://www.shnenglu.com/unixfy/archive/2013/09/14/203237.htmlhttp://www.shnenglu.com/unixfy/comments/203237.htmlhttp://www.shnenglu.com/unixfy/archive/2013/09/14/203237.html#Feedback0http://www.shnenglu.com/unixfy/comments/commentRss/203237.htmlhttp://www.shnenglu.com/unixfy/services/trackbacks/203237.html


鍗氬閲嶅畾鍚戣嚦


http://www.cnblogs.com/unixfy






unixfy 2013-09-14 23:49 鍙戣〃璇勮
]]>
lower_bound and upper_boundhttp://www.shnenglu.com/unixfy/archive/2013/05/30/200701.htmlunixfyunixfyThu, 30 May 2013 12:55:00 GMThttp://www.shnenglu.com/unixfy/archive/2013/05/30/200701.htmlhttp://www.shnenglu.com/unixfy/comments/200701.htmlhttp://www.shnenglu.com/unixfy/archive/2013/05/30/200701.html#Feedback0http://www.shnenglu.com/unixfy/comments/commentRss/200701.htmlhttp://www.shnenglu.com/unixfy/services/trackbacks/200701.htmlSTL algorithm 涓殑 lower_bound and upper_bound

lower_bound 榪斿洖鐨勭粨鏋?>= 鍙傛暟 value
upper_bound 榪斿洖鐨勭粨鏋?> 鍙傛暟 value

鍏蜂綋鏄庣粏鍙弬瑙佺櫨縐?br />lower_bound錛?a >http://baike.baidu.cn/view/4720650.htm
upper_bound錛?a >http://baike.baidu.cn/view/4163451.htm

嫻嬭瘯浠g爜錛?
 1 #include <iostream>
 2 #include <set>
 3 #include <algorithm>
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     set<int> si;
 9     //cout << si.insert(3) << endl;
10     cout << *(si.insert(3).first) << endl;
11     
12     for (int i = 1; i <= 10; i += 2)
13     {
14         si.insert(i);
15     }
16     for (set<int>::const_iterator cit = si.begin(); cit != si.end(); ++cit)
17     {
18         cout << *cit << ' ';
19     }
20     cout << endl;
21     
22     cout << endl;
23     cout << *lower_bound(si.begin(), si.end(), 3<< endl;
24     cout << *lower_bound(si.begin(), si.end(), 4<< endl;
25     cout << *lower_bound(si.begin(), si.end(), 5<< endl;
26     cout << *lower_bound(si.begin(), si.end(), 6<< endl;
27     
28     cout << endl;
29     cout << *upper_bound(si.begin(), si.end(), 3<< endl;
30     cout << *upper_bound(si.begin(), si.end(), 4<< endl;
31     cout << *upper_bound(si.begin(), si.end(), 5<< endl;
32     cout << *upper_bound(si.begin(), si.end(), 6<< endl;
33     
34     system("PAUSE");
35 }
36 

杈撳嚭錛?br />

3
1 3 5 7 9

3
5
5
7

5
5
7
7




unixfy 2013-05-30 20:55 鍙戣〃璇勮
]]>
瀛愮被鍖栧垪琛?/title><link>http://www.shnenglu.com/unixfy/archive/2013/05/21/200459.html</link><dc:creator>unixfy</dc:creator><author>unixfy</author><pubDate>Tue, 21 May 2013 14:14:00 GMT</pubDate><guid>http://www.shnenglu.com/unixfy/archive/2013/05/21/200459.html</guid><wfw:comment>http://www.shnenglu.com/unixfy/comments/200459.html</wfw:comment><comments>http://www.shnenglu.com/unixfy/archive/2013/05/21/200459.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/unixfy/comments/commentRss/200459.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/unixfy/services/trackbacks/200459.html</trackback:ping><description><![CDATA[<div style="font-size: 13px; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; border-bottom: #cccccc 1px solid; word-break: break-all; padding-bottom: 4px; padding-top: 4px; padding-left: 4px; border-left: #cccccc 1px solid; padding-right: 5px; width: 98%; background-color: #eeeeee"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080"> 1</span> <span style="color: #0000ff">class</span><span style="color: #000000"> CounterList(list):<br /></span><span style="color: #008080"> 2</span> <span style="color: #000000">    </span><span style="color: #0000ff">def</span><span style="color: #000000"> </span><span style="color: #800080">__init__</span><span style="color: #000000">(self, </span><span style="color: #000000">*</span><span style="color: #000000">args):<br /></span><span style="color: #008080"> 3</span> <span style="color: #000000">        super(CounterList, self).</span><span style="color: #800080">__init__</span><span style="color: #000000">(</span><span style="color: #000000">*</span><span style="color: #000000">args)<br /></span><span style="color: #008080"> 4</span> <span style="color: #000000">        self.counter </span><span style="color: #000000">=</span><span style="color: #000000"> 0<br /></span><span style="color: #008080"> 5</span> <span style="color: #000000"><br /></span><span style="color: #008080"> 6</span> <span style="color: #000000">    </span><span style="color: #0000ff">def</span><span style="color: #000000"> </span><span style="color: #800080">__getitem__</span><span style="color: #000000">(self, index):<br /></span><span style="color: #008080"> 7</span> <span style="color: #000000">        self.counter </span><span style="color: #000000">+=</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000"><br /></span><span style="color: #008080"> 8</span> <span style="color: #000000">        </span><span style="color: #0000ff">return</span><span style="color: #000000"> super(CounterList, self).</span><span style="color: #800080">__getitem__</span><span style="color: #000000">(index)<br /></span><span style="color: #008080"> 9</span> <span style="color: #000000"><br /></span><span style="color: #008080">10</span> <span style="color: #000000"><br /></span><span style="color: #008080">11</span> <span style="color: #000000">cl </span><span style="color: #000000">=</span><span style="color: #000000"> CounterList(range(</span><span style="color: #000000">10</span><span style="color: #000000">))<br /></span><span style="color: #008080">12</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(cl)<br /></span><span style="color: #008080">13</span> <span style="color: #000000">cl.reverse()<br /></span><span style="color: #008080">14</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(cl)<br /></span><span style="color: #008080">15</span> <span style="color: #000000"></span><span style="color: #0000ff">del</span><span style="color: #000000">(cl[</span><span style="color: #000000">3</span><span style="color: #000000">:</span><span style="color: #000000">6</span><span style="color: #000000">])<br /></span><span style="color: #008080">16</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(cl)<br /></span><span style="color: #008080">17</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(cl.counter)<br /></span><span style="color: #008080">18</span> <span style="color: #000000">cl[</span><span style="color: #000000">4</span><span style="color: #000000">] </span><span style="color: #000000">+</span><span style="color: #000000"> cl[</span><span style="color: #000000">2</span><span style="color: #000000">]<br /></span><span style="color: #008080">19</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(cl.counter)</span></div><br />杈撳嚭錛?br />>>> <br />[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]<br />[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]<br />[9, 8, 7, 3, 2, 1, 0]<br />0<br />2<img src ="http://www.shnenglu.com/unixfy/aggbug/200459.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/unixfy/" target="_blank">unixfy</a> 2013-05-21 22:14 <a href="http://www.shnenglu.com/unixfy/archive/2013/05/21/200459.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>瀹炵幇涓涓棤絀峰簭鍒?/title><link>http://www.shnenglu.com/unixfy/archive/2013/05/21/200457.html</link><dc:creator>unixfy</dc:creator><author>unixfy</author><pubDate>Tue, 21 May 2013 14:03:00 GMT</pubDate><guid>http://www.shnenglu.com/unixfy/archive/2013/05/21/200457.html</guid><wfw:comment>http://www.shnenglu.com/unixfy/comments/200457.html</wfw:comment><comments>http://www.shnenglu.com/unixfy/archive/2013/05/21/200457.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/unixfy/comments/commentRss/200457.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/unixfy/services/trackbacks/200457.html</trackback:ping><description><![CDATA[<div style="font-size: 13px; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; border-bottom: #cccccc 1px solid; word-break: break-all; padding-bottom: 4px; padding-top: 4px; padding-left: 4px; border-left: #cccccc 1px solid; padding-right: 5px; width: 98%; background-color: #eeeeee"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080"> 1</span> <span style="color: #0000ff">def</span><span style="color: #000000"> checkIndex(key):<br /></span><span style="color: #008080"> 2</span> <span style="color: #000000">    </span><span style="color: #0000ff">if</span><span style="color: #000000"> </span><span style="color: #0000ff">not</span><span style="color: #000000"> isinstance(key, (int,)):<br /></span><span style="color: #008080"> 3</span> <span style="color: #000000">        </span><span style="color: #0000ff">raise</span><span style="color: #000000"> TypeError<br /></span><span style="color: #008080"> 4</span> <span style="color: #000000">    </span><span style="color: #0000ff">if</span><span style="color: #000000"> key </span><span style="color: #000000"><</span><span style="color: #000000"> 0:<br /></span><span style="color: #008080"> 5</span> <span style="color: #000000">        </span><span style="color: #0000ff">raise</span><span style="color: #000000"> IndexError<br /></span><span style="color: #008080"> 6</span> <span style="color: #000000"><br /></span><span style="color: #008080"> 7</span> <span style="color: #000000"></span><span style="color: #0000ff">class</span><span style="color: #000000"> ArithmeticSequence:<br /></span><span style="color: #008080"> 8</span> <span style="color: #000000">    </span><span style="color: #0000ff">def</span><span style="color: #000000"> </span><span style="color: #800080">__init__</span><span style="color: #000000">(self, start </span><span style="color: #000000">=</span><span style="color: #000000"> 0, step </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">):<br /></span><span style="color: #008080"> 9</span> <span style="color: #000000">        self.start </span><span style="color: #000000">=</span><span style="color: #000000"> start<br /></span><span style="color: #008080">10</span> <span style="color: #000000">        self.step  </span><span style="color: #000000">=</span><span style="color: #000000"> step<br /></span><span style="color: #008080">11</span> <span style="color: #000000">        self.changed </span><span style="color: #000000">=</span><span style="color: #000000"> {}<br /></span><span style="color: #008080">12</span> <span style="color: #000000"><br /></span><span style="color: #008080">13</span> <span style="color: #000000">    </span><span style="color: #0000ff">def</span><span style="color: #000000"> </span><span style="color: #800080">__getitem__</span><span style="color: #000000">(self, key):<br /></span><span style="color: #008080">14</span> <span style="color: #000000"><br /></span><span style="color: #008080">15</span> <span style="color: #000000">        checkIndex(key)<br /></span><span style="color: #008080">16</span> <span style="color: #000000"><br /></span><span style="color: #008080">17</span> <span style="color: #000000">        </span><span style="color: #0000ff">print</span><span style="color: #000000">(</span><span style="color: #800000">'</span><span style="color: #800000">__getitem__</span><span style="color: #800000">'</span><span style="color: #000000">)<br /></span><span style="color: #008080">18</span> <span style="color: #000000"><br /></span><span style="color: #008080">19</span> <span style="color: #000000">        </span><span style="color: #0000ff">try</span><span style="color: #000000">:<br /></span><span style="color: #008080">20</span> <span style="color: #000000">            </span><span style="color: #0000ff">return</span><span style="color: #000000"> self.changed[key]<br /></span><span style="color: #008080">21</span> <span style="color: #000000">        </span><span style="color: #0000ff">except</span><span style="color: #000000"> KeyError:<br /></span><span style="color: #008080">22</span> <span style="color: #000000">            </span><span style="color: #0000ff">return</span><span style="color: #000000"> self.start </span><span style="color: #000000">+</span><span style="color: #000000"> key </span><span style="color: #000000">*</span><span style="color: #000000"> self.step<br /></span><span style="color: #008080">23</span> <span style="color: #000000"><br /></span><span style="color: #008080">24</span> <span style="color: #000000">    </span><span style="color: #0000ff">def</span><span style="color: #000000"> </span><span style="color: #800080">__setitem__</span><span style="color: #000000">(self, key, value):<br /></span><span style="color: #008080">25</span> <span style="color: #000000"><br /></span><span style="color: #008080">26</span> <span style="color: #000000">        checkIndex(key)<br /></span><span style="color: #008080">27</span> <span style="color: #000000"><br /></span><span style="color: #008080">28</span> <span style="color: #000000">        </span><span style="color: #0000ff">print</span><span style="color: #000000">(</span><span style="color: #800000">'</span><span style="color: #800000">__setitem__</span><span style="color: #800000">'</span><span style="color: #000000">)<br /></span><span style="color: #008080">29</span> <span style="color: #000000"><br /></span><span style="color: #008080">30</span> <span style="color: #000000">        self.changed[key] </span><span style="color: #000000">=</span><span style="color: #000000"> value<br /></span><span style="color: #008080">31</span> <span style="color: #000000"><br /></span><span style="color: #008080">32</span> <span style="color: #000000"><br /></span><span style="color: #008080">33</span> <span style="color: #000000">s </span><span style="color: #000000">=</span><span style="color: #000000"> ArithmeticSequence(</span><span style="color: #000000">1</span><span style="color: #000000">, </span><span style="color: #000000">2</span><span style="color: #000000">)<br /></span><span style="color: #008080">34</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(s[</span><span style="color: #000000">4</span><span style="color: #000000">])<br /></span><span style="color: #008080">35</span> <span style="color: #000000">s[</span><span style="color: #000000">4</span><span style="color: #000000">] </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">2</span><span style="color: #000000"><br /></span><span style="color: #008080">36</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(s[</span><span style="color: #000000">4</span><span style="color: #000000">])<br /></span><span style="color: #008080">37</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(s[</span><span style="color: #000000">5</span><span style="color: #000000">])<br /></span><span style="color: #008080">38</span> <span style="color: #000000">s[</span><span style="color: #000000">3</span><span style="color: #000000">] </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">100</span><span style="color: #000000"><br /></span><span style="color: #008080">39</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(s[</span><span style="color: #000000">3</span><span style="color: #000000">])<br /></span><span style="color: #008080">40</span> <span style="color: #000000">s.</span><span style="color: #800080">__setitem__</span><span style="color: #000000">(</span><span style="color: #000000">100</span><span style="color: #000000">, </span><span style="color: #000000">3</span><span style="color: #000000">)<br /></span><span style="color: #008080">41</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(s.</span><span style="color: #800080">__getitem__</span><span style="color: #000000">(</span><span style="color: #000000">100</span><span style="color: #000000">))</span></div><br />杈撳嚭錛?br />>>> <br />__getitem__<br />9<br />__setitem__<br />__getitem__<br />2<br />__getitem__<br />11<br />__setitem__<br />__getitem__<br />100<br />__setitem__<br />__getitem__<br />3<img src ="http://www.shnenglu.com/unixfy/aggbug/200457.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/unixfy/" target="_blank">unixfy</a> 2013-05-21 22:03 <a href="http://www.shnenglu.com/unixfy/archive/2013/05/21/200457.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Python 緇ф壙-瀹炵幇涓涓繃婊ゅ櫒http://www.shnenglu.com/unixfy/archive/2013/05/19/200391.htmlunixfyunixfySun, 19 May 2013 03:39:00 GMThttp://www.shnenglu.com/unixfy/archive/2013/05/19/200391.htmlhttp://www.shnenglu.com/unixfy/comments/200391.htmlhttp://www.shnenglu.com/unixfy/archive/2013/05/19/200391.html#Feedback0http://www.shnenglu.com/unixfy/comments/commentRss/200391.htmlhttp://www.shnenglu.com/unixfy/services/trackbacks/200391.html 1 class Filter:
 2     def init(self):
 3         self.blocked = []
 4     def filter(self, sequence):
 5         return [x for x in sequence if x not in self.blocked]
 6 
 7 class SPAMFilter(Filter): # SPAMFilter 鏄?nbsp;Filter 鐨勫瓙綾?/span>
 8     def init(self):
 9         self.blocked = ['SPAM']
10 
11 = Filter()
12 f.init()
13 print(f.filter([123]))
14 
15 = SPAMFilter()
16 s.init()
17 print(s.filter(['SPAM''SPAM''SPAM''SPAM''eggs''bacon''SPAM']))
杈撳嚭錛?br />>>>
[1, 2, 3]
['eggs', 'bacon']

unixfy 2013-05-19 11:39 鍙戣〃璇勮
]]>
Python 涓被鐨勯潤鎬佹垚鍛樹笌鏅氭垚鍛?/title><link>http://www.shnenglu.com/unixfy/archive/2013/05/18/200381.html</link><dc:creator>unixfy</dc:creator><author>unixfy</author><pubDate>Sat, 18 May 2013 08:43:00 GMT</pubDate><guid>http://www.shnenglu.com/unixfy/archive/2013/05/18/200381.html</guid><wfw:comment>http://www.shnenglu.com/unixfy/comments/200381.html</wfw:comment><comments>http://www.shnenglu.com/unixfy/archive/2013/05/18/200381.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/unixfy/comments/commentRss/200381.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/unixfy/services/trackbacks/200381.html</trackback:ping><description><![CDATA[<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080"> 1</span> <span style="color: #0000ff">class</span><span style="color: #000000"> MemberCounter:<br /></span><span style="color: #008080"> 2</span> <span style="color: #000000">    member </span><span style="color: #000000">=</span><span style="color: #000000"> 0<br /></span><span style="color: #008080"> 3</span> <span style="color: #000000">    </span><span style="color: #0000ff">def</span><span style="color: #000000"> init(self):<br /></span><span style="color: #008080"> 4</span> <span style="color: #000000">        self.member </span><span style="color: #000000">+=</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000"><br /></span><span style="color: #008080"> 5</span> <span style="color: #000000">        MemberCounter.member </span><span style="color: #000000">+=</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000"><br /></span><span style="color: #008080"> 6</span> <span style="color: #000000"><br /></span><span style="color: #008080"> 7</span> <span style="color: #000000">m1 </span><span style="color: #000000">=</span><span style="color: #000000"> MemberCounter()<br /></span><span style="color: #008080"> 8</span> <span style="color: #000000">m1.init()<br /></span><span style="color: #008080"> 9</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(m1.member)<br /></span><span style="color: #008080">10</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(MemberCounter.member)<br /></span><span style="color: #008080">11</span> <span style="color: #000000"><br /></span><span style="color: #008080">12</span> <span style="color: #000000">m2 </span><span style="color: #000000">=</span><span style="color: #000000"> MemberCounter()<br /></span><span style="color: #008080">13</span> <span style="color: #000000">m2.init()<br /></span><span style="color: #008080">14</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(m2.member)<br /></span><span style="color: #008080">15</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(MemberCounter.member)<br /></span><span style="color: #008080">16</span> <span style="color: #000000"><br /></span><span style="color: #008080">17</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(m1.member </span><span style="color: #0000ff">is</span><span style="color: #000000"> m2.member)<br /></span><span style="color: #008080">18</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(m1.member </span><span style="color: #0000ff">is</span><span style="color: #000000"> MemberCounter.member)<br /></span><span style="color: #008080">19</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(m2.member </span><span style="color: #0000ff">is</span><span style="color: #000000"> MemberCounter.member)<br /></span><span style="color: #008080">20</span> <span style="color: #000000"><br /></span><span style="color: #008080">21</span> <span style="color: #000000">m3 </span><span style="color: #000000">=</span><span style="color: #000000"> MemberCounter()<br /></span><span style="color: #008080">22</span> <span style="color: #000000">m3.init()<br /></span><span style="color: #008080">23</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(m3.member)<br /></span><span style="color: #008080">24</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(MemberCounter.member)<br /></span><span style="color: #008080">25</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(m2.member </span><span style="color: #0000ff">is</span><span style="color: #000000"> MemberCounter.member)<br /></span><span style="color: #008080">26</span> <span style="color: #000000"><br /></span><span style="color: #008080">27</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(m1.member)<br /></span><span style="color: #008080">28</span> <span style="color: #000000"></span><span style="color: #0000ff">print</span><span style="color: #000000">(MemberCounter.member)</span></div> <div><br />杈撳嚭錛?br />>>> <br />1<br />1<br />2<br />2<br />False<br />False<br />True<br />3<br />3<br />False<br />1<br />3</div><img src ="http://www.shnenglu.com/unixfy/aggbug/200381.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/unixfy/" target="_blank">unixfy</a> 2013-05-18 16:43 <a href="http://www.shnenglu.com/unixfy/archive/2013/05/18/200381.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Python 縐佹湁鎴愬憳鐨勮闂?/title><link>http://www.shnenglu.com/unixfy/archive/2013/05/18/200380.html</link><dc:creator>unixfy</dc:creator><author>unixfy</author><pubDate>Sat, 18 May 2013 08:31:00 GMT</pubDate><guid>http://www.shnenglu.com/unixfy/archive/2013/05/18/200380.html</guid><wfw:comment>http://www.shnenglu.com/unixfy/comments/200380.html</wfw:comment><comments>http://www.shnenglu.com/unixfy/archive/2013/05/18/200380.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/unixfy/comments/commentRss/200380.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/unixfy/services/trackbacks/200380.html</trackback:ping><description><![CDATA[<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080"> 1</span> <span style="color: #800080">__metaclass__</span><span style="color: #000000"> </span><span style="color: #000000">=</span><span style="color: #000000"> type </span><span style="color: #008000">#</span><span style="color: #008000"> 紜畾浣跨敤鏂板紡綾?/span><span style="color: #008000"><br /></span><span style="color: #008080"> 2</span> <span style="color: #008000"></span><span style="color: #000000"><br /></span><span style="color: #008080"> 3</span> <span style="color: #000000"></span><span style="color: #0000ff">class</span><span style="color: #000000"> Person:<br /></span><span style="color: #008080"> 4</span> <span style="color: #000000"><br /></span><span style="color: #008080"> 5</span> <span style="color: #000000">    </span><span style="color: #0000ff">def</span><span style="color: #000000"> setName(self, name):<br /></span><span style="color: #008080"> 6</span> <span style="color: #000000">        self.name </span><span style="color: #000000">=</span><span style="color: #000000"> name<br /></span><span style="color: #008080"> 7</span> <span style="color: #000000"><br /></span><span style="color: #008080"> 8</span> <span style="color: #000000">    </span><span style="color: #0000ff">def</span><span style="color: #000000"> getName(self):<br /></span><span style="color: #008080"> 9</span> <span style="color: #000000">        </span><span style="color: #0000ff">return</span><span style="color: #000000"> self.name<br /></span><span style="color: #008080">10</span> <span style="color: #000000"><br /></span><span style="color: #008080">11</span> <span style="color: #000000">    </span><span style="color: #0000ff">def</span><span style="color: #000000"> greet(self):<br /></span><span style="color: #008080">12</span> <span style="color: #000000">        </span><span style="color: #0000ff">print</span><span style="color: #000000">(</span><span style="color: #800000">"</span><span style="color: #800000">Hello, world! I'm %s.</span><span style="color: #800000">"</span><span style="color: #000000"> </span><span style="color: #000000">%</span><span style="color: #000000"> self.name)<br /></span><span style="color: #008080">13</span> <span style="color: #000000"><br /></span><span style="color: #008080">14</span> <span style="color: #000000">    </span><span style="color: #0000ff">def</span><span style="color: #000000"> </span><span style="color: #800080">__foo</span><span style="color: #000000">(self):<br /></span><span style="color: #008080">15</span> <span style="color: #000000">        </span><span style="color: #0000ff">print</span><span style="color: #000000">(</span><span style="color: #800000">"</span><span style="color: #800000">FOO</span><span style="color: #800000">"</span><span style="color: #000000">, self.name)<br /></span><span style="color: #008080">16</span> <span style="color: #000000">    </span><span style="color: #0000ff">def</span><span style="color: #000000"> _bar(self):<br /></span><span style="color: #008080">17</span> <span style="color: #000000">        </span><span style="color: #0000ff">print</span><span style="color: #000000">(</span><span style="color: #800000">"</span><span style="color: #800000">BAR</span><span style="color: #800000">"</span><span style="color: #000000">, self.name)<br /></span><span style="color: #008080">18</span> <span style="color: #000000"><br /></span><span style="color: #008080">19</span> <span style="color: #000000"><br /></span><span style="color: #008080">20</span> <span style="color: #000000">foo </span><span style="color: #000000">=</span><span style="color: #000000"> Person()<br /></span><span style="color: #008080">21</span> <span style="color: #000000">bar </span><span style="color: #000000">=</span><span style="color: #000000"> Person()<br /></span><span style="color: #008080">22</span> <span style="color: #000000">foo.setName(</span><span style="color: #800000">'</span><span style="color: #800000">Luke Skywalker</span><span style="color: #800000">'</span><span style="color: #000000">)<br /></span><span style="color: #008080">23</span> <span style="color: #000000">bar.setName(</span><span style="color: #800000">'</span><span style="color: #800000">Anakin Skywalker</span><span style="color: #800000">'</span><span style="color: #000000">)<br /></span><span style="color: #008080">24</span> <span style="color: #000000">foo.greet()<br /></span><span style="color: #008080">25</span> <span style="color: #000000">bar.greet()<br /></span><span style="color: #008080">26</span> <span style="color: #000000">Person.greet(bar)<br /></span><span style="color: #008080">27</span> <span style="color: #000000"><br /></span><span style="color: #008080">28</span> <span style="color: #000000"></span><span style="color: #008000">#</span><span style="color: #008000"> foo.__foo()</span><span style="color: #008000"><br /></span><span style="color: #008080">29</span> <span style="color: #008000"></span><span style="color: #000000">foo._Person__foo()<br /></span><span style="color: #008080">30</span> <span style="color: #000000">foo._bar()<br /></span><span style="color: #008080">31</span> <span style="color: #000000"></span><span style="color: #008000">#</span><span style="color: #008000"> foo._Person_bar()</span></div><br />杈撳嚭錛?br />>>> <br />Hello, world! I'm Luke Skywalker.<br />Hello, world! I'm Anakin Skywalker.<br />Hello, world! I'm Anakin Skywalker.<br />FOO Luke Skywalker<br />BAR Luke Skywalker<img src ="http://www.shnenglu.com/unixfy/aggbug/200380.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/unixfy/" target="_blank">unixfy</a> 2013-05-18 16:31 <a href="http://www.shnenglu.com/unixfy/archive/2013/05/18/200380.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鑷畾涔?Python range 鍑芥暟 2http://www.shnenglu.com/unixfy/archive/2013/05/18/200375.htmlunixfyunixfySat, 18 May 2013 06:32:00 GMThttp://www.shnenglu.com/unixfy/archive/2013/05/18/200375.htmlhttp://www.shnenglu.com/unixfy/comments/200375.htmlhttp://www.shnenglu.com/unixfy/archive/2013/05/18/200375.html#Feedback0http://www.shnenglu.com/unixfy/comments/commentRss/200375.htmlhttp://www.shnenglu.com/unixfy/services/trackbacks/200375.html 1 def my_range_2(start, stop = None, step = 1):
 2     if stop == None:
 3         if start > 0:
 4             start, stop = 0, start
 5         else:
 6             start, stop = start, 0
 7     result = []
 8     if step > 0 and start < stop:
 9         i = start
10         while (i < stop):
11             result.append(i)
12             i += step
13     elif step < 0 and start > stop:
14         i = start
15         while i > stop:
16             result.append(i)
17             i += step
18     return result
19 
20 print(my_range_2(10))
21 print(my_range_2(5202))
22 print(my_range_2(110))
23 print(my_range_2(10, 0, -1))
24 print(my_range_2(100, 0, -9))
25 print(my_range_2(1020-5))
26 
27 print(my_range_2(100, 0, -10))
28 print(my_range_2(-10))
29 print(my_range_2(-10-51))
30 print(my_range_2(-10-201))
31 print(my_range_2(-50-45))
>>>
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[5, 7, 9, 11, 13, 15, 17, 19]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
[100, 91, 82, 73, 64, 55, 46, 37, 28, 19, 10, 1]
[]
[100, 90, 80, 70, 60, 50, 40, 30, 20, 10]
[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]
[-10, -9, -8, -7, -6]
[]
[-50, -49, -48, -47, -46]

unixfy 2013-05-18 14:32 鍙戣〃璇勮
]]>
Python 閫掑綊浜屽垎鏌ユ壘http://www.shnenglu.com/unixfy/archive/2013/05/16/200337.htmlunixfyunixfyThu, 16 May 2013 14:24:00 GMThttp://www.shnenglu.com/unixfy/archive/2013/05/16/200337.htmlhttp://www.shnenglu.com/unixfy/comments/200337.htmlhttp://www.shnenglu.com/unixfy/archive/2013/05/16/200337.html#Feedback0http://www.shnenglu.com/unixfy/comments/commentRss/200337.htmlhttp://www.shnenglu.com/unixfy/services/trackbacks/200337.html 1 def search(sequence, number, lower = 0, upper = None):
 2     if upper is None:
 3         upper = len(sequence) - 1
 4     if lower == upper:
 5         assert(number == sequence[upper])
 6         return upper
 7     else:
 8         middle = (lower + upper) // 2
 9         if number > sequence[middle]:
10             return search(sequence, number, middle + 1, upper)
11         else:
12             return search(sequence, number, lower, middle)
13 
14 seq = [34678123410095]
15 print(seq)
16 seq.sort()
17 print(seq)
18 print(search(seq, 34))
19 print(search(seq, 100))
杈撳嚭錛?br />[34, 67, 8, 123, 4, 100, 95]
[4, 8, 34, 67, 95, 100, 123]
2
5

unixfy 2013-05-16 22:24 鍙戣〃璇勮
]]>
浣曚負(fù)闂寘http://www.shnenglu.com/unixfy/archive/2013/05/16/200336.htmlunixfyunixfyThu, 16 May 2013 13:18:00 GMThttp://www.shnenglu.com/unixfy/archive/2013/05/16/200336.htmlhttp://www.shnenglu.com/unixfy/comments/200336.htmlhttp://www.shnenglu.com/unixfy/archive/2013/05/16/200336.html#Feedback0http://www.shnenglu.com/unixfy/comments/commentRss/200336.htmlhttp://www.shnenglu.com/unixfy/services/trackbacks/200336.html 1 def multiplier(factor):
 2     def multiply_by_factor(number):
 3         return number * factor
 4     return multiply_by_factor
 5 
 6 
 7 double = multiplier(2# factor = 2
 8 print(double(5))       # number = 5
 9 triple = multiplier(3# factor = 3
10 print(triple(4))       # number = 4
11 print(multiplier(5)(4))# factor = 5, number = 4
杈撳嚭錛?br />>>>
10
12
20

unixfy 2013-05-16 21:18 鍙戣〃璇勮
]]>
狠狠色丁香久久婷婷综合蜜芽五月 | 亚洲国产小视频精品久久久三级| 97久久精品无码一区二区天美 | 国产高潮国产高潮久久久91 | 国产一区二区久久久| 精品无码久久久久久久动漫| 99久久国产热无码精品免费久久久久| 久久天天躁狠狠躁夜夜avapp| 色偷偷88888欧美精品久久久 | 久久久久久青草大香综合精品| 91久久精品国产91性色也| 久久er热视频在这里精品| 香蕉久久夜色精品国产小说| 久久精品国产福利国产秒| 丁香久久婷婷国产午夜视频| 久久国产精品波多野结衣AV| 久久亚洲av无码精品浪潮| 99精品国产免费久久久久久下载| 99久久香蕉国产线看观香| 亚洲αv久久久噜噜噜噜噜| 久久久一本精品99久久精品66| 久久美女人爽女人爽| 久久久99精品成人片中文字幕| 亚洲精品tv久久久久久久久久| 国内精品伊人久久久久777| 99久久无码一区人妻a黑| 99久久精品久久久久久清纯| 午夜精品久久久久成人| 久久精品水蜜桃av综合天堂| yellow中文字幕久久网| 精品国产99久久久久久麻豆 | 91精品观看91久久久久久| 久久久久99精品成人片牛牛影视| 欧美亚洲国产精品久久高清| 国产精品一久久香蕉国产线看观看 | 久久亚洲AV无码精品色午夜麻豆 | 无码人妻久久一区二区三区蜜桃| 狠狠色丁香久久婷婷综合五月| 久久高潮一级毛片免费| 久久丫忘忧草产品| 久久99亚洲综合精品首页|