¡¾Python¡¿ÓÃPythonÀ´ÊµÏÖ´Õ24µÄ³ÌÐò
´Õ24ÊǾµäµÄÒæÖÇÓÎÏ·£¬¶àÍæ¿ÉÒÔʹÄÔ½îÁé»îÒ»µã£¬µ«Êǵ±Óöµ½ÎÞ½âµÄʱºò£¬¾Í»áºÜÉËÄԽΪ´Ë£¬Ð´¸ö³ÌÐòÀ´´úΪ¼ÆËã¡£
ÔËÐнá¹û£¬È¥³ýÁËÖظ´µÄһЩ±í´ïʽ£º
entry: 1
entry: 4
entry: 5
entry: 6
(4/(1-(5/6))) = 24
(6/((5/4)-1)) = 24
Press any key to exit...
entry: 3
entry: 3
entry: 8
entry: 8
(8/(3-(8/3))) = 24
Press any key to exit...
¸½Ô´Â룺
NUMBER=4
TOTAL=24
class data:
pass
def Simplify(a, b):
desta=a;destb=b
if b==0 or b==1:return desta, destb
if a==0 or a==1:return desta, destb
if a>b:n=b
else:n=a
for i in range(2,n+1):
while n != i:
if a%i==0 and b%i==0:
a=a/i;b=b/i;n=n/i
else:break
if a%n==0 and b%n==0:
a=a/n;b=b/n
desta=a;destb=b
return desta, destb
def MergeList(L1, L2):
LSum=[]
if L1==[]:
for i in range(len(L2)):
LSum.append(L2[i])
return LSum
if L2==[]:
for i in range(len(L1)):
LSum.append(L1[i])
return LSum
#fenmu:denominator fenzi:numerator
#L:0 fenzi 1 fenmu 2 format
for i in range(len(L1)):
for j in range(len(L2)):
#+
tempa=L1[i].a * L2[j].b + L1[i].b * L2[j].a
tempb=L1[i].b * L2[j].b
tempobj=data()
tempobj.a, tempobj.b = Simplify(tempa, tempb)
if tempobj.a == 0:tempobj.b=1
tempobj.c = "(%s+%s)" % (L1[i].c, L2[j].c)
LSum.append(tempobj)
#-
tempa=abs(L1[i].a * L2[j].b - L1[i].b * L2[j].a)
tempb=L1[i].b * L2[j].b
tempobj=data()
tempobj.a, tempobj.b = Simplify(tempa, tempb)
if tempobj.a == 0:tempobj.b=1
if L1[i].a * L2[j].b > L1[i].b * L2[j].a:
tempobj.c = "(%s-%s)" % (L1[i].c, L2[j].c)
else:tempobj.c = "(%s-%s)" % (L2[j].c, L1[i].c)
LSum.append(tempobj)
#*
tempa
Ïà¹ØÎĵµ£º
¹¤¾ßÀ¸->¸ß¼¶->ÅäÖÃ->±à¼Æ÷ÏÔʾ->Óï·¨¼ÓÁÁ->´ò¿ª
ÔÚ´ò¿ªµÄÎļþÖнáβ¼ÓÉÏÏÂÃæÎÄ×Ö£¬²¢±£´æ¡£
/L10"Python" Line Comment = # Block Comment One = """ Block Comment Off = """ Escape Char = \ File Extensions = PY PYW
/Indent Strings = ":"
/Function String 1 = "%[ ,^t]++def[ ]+^([a-zA-Z0-9_] ......
int main()
{
int a[] = {1,2,3,4,5};
int i;
int * p = a;
for (p = a + 4, i = 0; i < 5; i++) {
printf("%d ",p[-i]);
}
return 0;
}
......
¹«Ë¾µÄ´úÀí¿ÉÒÔÖ±½Ó´©Ç½£¬×ÔÓÉ·ÃÎÊTwitter¡¢FacebookµÈÍøÕ¾£¬ÕâÁ½ÌìÑо¿ÁËÒ»ÏÂTwitterÌṩµÄAPI£¬ÓÃpythonдÁËÒ»¸ötwitter client£¬Ö»ÊµÏÖÁË»ù±¾¹¦ÄÜ£¬²é¿´×Ô¼ºµÄtwitterÏûÏ¢£¬Ò²¿ÉÒÔ²»ÑéÖ¤£¬²é¿´publicµÄtwitterÏûÏ¢¡£ÆäËû¹¦ÄÜʵÏÖÀàËÆ¡£Ö÷Òªº¯ÊýÈçÏ£º
def fetch_with_proxy(proxy, username, password, url):
&n ......
#!/usr/bin/python
#coding=utf-8
import Image,ImageDraw,ImageFont,os,string,random,ImageFilter
def initChars():
"""
ÔÊÐíµÄ×Ö·û¼¯ºÏ£¬³õʼ¼¯ºÏΪÊý×Ö¡¢´óСд×Öĸ
usage: initChars()
param: None
return: list
·µ»ØÔÊÐíµÄ×Ö·û¼¯ºÍ
for: picCheckerÀà³õʼ×Ö·û¼¯ºÏ
todo: ......
1¡¢ÔÚPythonÖÐ×î»ù±¾µÄÊý¾Ý½á¹¹ÊÇÐòÁУ¨sequence£©£¬ÐòÁÐÖеÄÿ¸öÔªËر»·ÖÅäÒ»¸öÊý×Ö——ÔªËصÄλÖã¬Ò²½ÐË÷Òý¡£µÚÒ»¸öË÷ÒýÊÇ 0£¬µÚ¶þ¸öË÷ÒýÊÇ1£¬Èç´ËµÝÍÆ¡£ÐòÁÐÖеÄ×îºóÒ»¸öÌõÄ¿±»±ê¼ÇΪ-1£¬µ¹ÊýµÚ¶þÊÇ-2£¬Èç´ËµÝÍÆ¡£
2¡¢ÐòÁУºeg:edward = ['Edward Gumby', 42]£¬ÐòÁÐÒ²ÄÜ°üº¬ÆäËûµÄÐòÁС£Ð ......