- 论坛徽章:
- 0
|
写程序讲求实用,我这个速度还可以,而且也容易看懂。
你们搞那么多花里胡哨的东西,吓唬人还可以,呵呵。
#
a = '''Obama has not talked with the men in the past few weeks, friends said, and some of the president-elect's associates dismissed his connection to the trio as coincidence. But, if nothing else, the image of all three standing together in front of flashing cameras served as a reminder of the political environment in which Obama developed: Blagojevich is awaiting an indictment; Burris may be blocked from claiming the Senate seat by leaders in Illinois and Washington; and Rush pushed for a black senator to replace Obama, who prefers not to participate in "the politics of race."
'''
b = '''It wasn't the first time race had come up between Rush and Obama. Rush, a former Black Panther who represents Chicago's South Side, defeated Obama in 2000 because he dominated the black vote. During the campaign, he collected the endorsements of almost every major black politician in Chicago -- including Burris -- and depicted Obama as a foreigner to black culture. "Barack is a person who read about the civil rights protests and thinks he knows all about it," Rush said.
'''
dic = {}
for i in range(len(a)):
for j in range(len(a),0,-1):
if i<j:
dic[a[i:j]] = 0
dic2 = {}
for i in range(len(b)):
for j in range(len(b),0,-1):
if i<j:
dic2[b[i:j]] = 0
n = 0
s = 0
for i in dic.keys():
if dic2.has_key(i) and len(i)>n:
n = len(i)
s = i[:]
print '"%s"'%s
[ 本帖最后由 julyzergcn 于 2008-12-31 16:02 编辑 ] |
|