和儿子一块学PYTHON . 感觉和C 语言基础的没有什么不同。感觉还不如C语言灵活。
编程语言,一通百通。
题目见下图。
结题思路:
这是一个最简单的密码加密方法。 而且告诉了密钥的长度= 3位,还是不重复的。
因为明码里有34和 3 ,可以缩小检索的范围。
用穷举法算出大于0 和小于26 的所有字母,并显示出来。 看看那个认识 就是那个。
程序如下:
# A B C #
#元组, 不可更改的数组
def myfirstdef():
aa= 0
while aa < 90:
print (tupabc [tup[aa] - A], end = "")
aa =aa + 1
if ((aa == 4) or (aa ==8)):
print (",",end = "")
if (aa > 90): break;
print (tupabc [tup[aa] - B],end = "")
aa = aa + 1
if ((aa == 4) or (aa ==8)):
print (",",end = "")
if (aa > 90):break;
print (tupabc [tup[aa] - C],end = "")
aa = aa + 1
if ((aa == 4) or (aa ==8)):
print (",",end = "")
if (aa > 90): break;
aa=0
con_v = 90 #这是元组的最大容量
v123_count = 0
v1 = 0
v2 = 1
v3 = 2
tup=(27,7,21,16,6,24,18,7,34,19,23,22,25,21,29,6,7,10,11,7,23,13,23,28,16,11,20,9,15,14,16,17,24,15,17,30,24,8,24,22,15,34,19,22,17,9,20,13,13,3,11,18,14,18,7,3,21,7,10,10,16,14,14,18,9,14,23,11,23,24,10,14,17,23,27,8,7,27,19,23,28,17,3,29,12,21,11,19,17,20,23)
tupabc=("a","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")
for A in(1,2,3,4,5,6,7,8,9):
for B in (1,2):
for C in (8,9):
while v123_count < 30 : # con_v/ 3 把数组中的数全检查一遍
#----------------------------------------------------A
if ((tup[v1] -A) <= 0) :### 跳出本次大循环
print ("AAAA小于0 跳出本次大循环 A ==",A,"B==",B,"C==",C,"v1==",v1,"tup[v1]==",tup[v1])
v1 =0
break
if ( (tup[v1] -A) > 26): #跳出本次循环
print ("AAA跳出本次循环 A ==",A,"B==",B,"C==",C,"v1==",v1,"tup[v1]==",tup[v1])
continue # 错误退出
else:
print ("AA ==",A,"B==",B,"C==",C,"v1==",v1,"tup[v1]==",tup[v1])
aa = tup[v1] -A
print (tupabc[aa])
v1 = v1 + 3 #
if (v1 > con_v) :
v1 = v1 -3
print ("a元组的容量超了,内存溢出,说明全部数据正确A ==",A,"B==",B,"C==",C,"v1==",v1,"tup[v1]",tup[v1])
myfirstdef()
break
#----------------------------------------------------B
if ((tup[v2] -B) <= 0):
print ("BBB 小于0 跳出本次大循环 A ==",A,"B==",B,"C==",C,"v2==",v2,"tup[v2]",tup[v2])
v2 =0
break
if (( (tup[v2] -B) > 26 )):
print ("BBB跳出本次循环 A ==",A,"B==",B,"C==",C,"v2==",v2,"tup[v2]==",tup[v2])
continue # 错误退出
else :
print ("A ==",A,"BB==",B,"C==",C,"v1==",v1,"tup[v1]==",tup[v1])
aa = tup[v2] -B
print (tupabc[aa])
v2 = v2 + 3 #
if (v2 > con_v):
v2 = v2 -3
print ("b元组的容量超了,内存溢出说明全部数据正确A ==",A,"B==",B,"C==",C,"v2==",v2,"tup[v2]",tup[v2])
myfirstdef()
break
#----------------------------------------------------C
if ((tup[v3] -C) <= 0):
print ("CCC 小于0 跳出本次大循环A ==",A,"B==",B,"C==",C,"v3==",v3,"tup[v3]",tup[v3])
v3 =0
break
if ( (tup[v3] -C) > 26 ):
print ("CCC 跳出本次循环A ==",A,"B==",B,"C==",C,"v3==",v3,"tup[v3]",tup[v3])
continue
else:
print ("A ==",A,"B==",B,"CC==",C,"v1==",v1,"tup[v1]==",tup[v1])
aa = tup[v3] -C
print (tupabc[aa])
v3 = v3 + 3
if (v3 > con_v):
v3 = v3 -3
print ("c元组的容量超了,内存溢出说明全部数据正确A ==",A,"B==",B,"C==",C,"v3==",v3,"tup[v3]",tup[v3])
myfirstdef()
break
v123_count = v123_count + 1
#----------------------------------------------------
#如果都没有问题,都是大于0的数,那输出A,B,C 的值
print ("A == B== C==",A,B,C)
#---------------------------------------
运算结果如下:
b元组的容量超了,内存溢出说明全部数据正确A == 1 B== 1 C== 8 v2== 88 tup[v2] 17
zfmo,epqf,zrvnxtuefbjfolvtojlhnfoppnpvwgpunzruihselbcqmjfbmfibomfqhfvjowifpvsgfsrvtpbuktcrplAA == 1 B== 1 C== 9 v1== 90 tup[v1]== 23
v
a元组的容量超了,内存溢出,说明全部数据正确A == 1 B== 1 C== 9 v1== 90 tup[v1] 23
zflo,eoqf,yrvmxttefajfnlvsojkhneoponpuwgounyruhhsdlbbqmifblfiaomeqhevjnwiepvrgfrrvspbtktbrpkAA == 1 B== 2 C== 8 v1== 90 tup[v1]== 23
v
a元组的容量超了,内存溢出,说明全部数据正确A == 1 B== 2 C== 8 v1== 90 tup[v1] 23
zemo,dpqe,zrunxsueebjeolutoilhmfoopnovwfpumzrtihrelacqljfamfhbolfqgfviowhfpusgesrutpaukscrolAA == 1 B== 2 C== 9 v1== 90 tup[v1]== 23
v
a元组的容量超了,内存溢出,说明全部数据正确A == 1 B== 2 C== 9 v1== 90 tup[v1] 23
zelo,doqe,yrumxsteeajenlusoikhmeooonouwfoumyrthhrdlabqlifalfhaoleqgevinwhepurgerruspatksbrokAA == 2 B== 1 C== 8 v1== 90 tup[v1]== 23
u
a元组的容量超了,内存溢出,说明全部数据正确A == 2 B== 1 C== 8 v1== 90 tup[v1] 23
yfmn,eppf,zqvnwtudfbifokvtnjlgnfnppmpvvgptnzquigsekbcpmjebmeibnmfphfujovifovsffsqvtobujtcqplAA == 2 B== 1 C== 9 v1== 90 tup[v1]== 23
u
a元组的容量超了,内存溢出,说明全部数据正确A == 2 B== 1 C== 9 v1== 90 tup[v1] 23
yfln,eopf,yqvmwttdfaifnkvsnjkgnenpompuvgotnyquhgsdkbbpmiebleianmepheujnvieovrffrqvsobtjtbqpkAA == 2 B== 2 C== 8 v1== 90 tup[v1]== 23
u
a元组的容量超了,内存溢出,说明全部数据正确A == 2 B== 2 C== 8 v1== 90 tup[v1] 23
yemn,dppe,zqunwsudebieokutnilgmfnopmovvfptmzqtigrekacpljeamehbnlfpgfuiovhfousfesqutoaujscqolAA == 2 B== 2 C== 9 v1== 90 tup[v1]== 23
u
a元组的容量超了,内存溢出,说明全部数据正确A == 2 B== 2 C== 9 v1== 90 tup[v1] 23
yeln,dope,yqumwstdeaienkusnikgmenoomouvfotmyqthgrdkabpliealehanlepgeuinvheourferqusoatjsbqokAA == 3 B== 1 C== 8 v1== 90 tup[v1]== 23
t
a元组的容量超了,内存溢出,说明全部数据正确A == 3 B== 1 C== 8 v1== 90 tup[v1] 23
xfmm,epof,zpvnvtucfbhfojvtmjlfnfmpplpvugpsnzpuifsejbcomjdbmdibmmfohftjouifnvsefspvtnbuitcpplAA == 3 B== 1 C== 9 v1== 90 tup[v1]== 23
t
a元组的容量超了,内存溢出,说明全部数据正确A == 3 B== 1 C== 9 v1== 90 tup[v1] 23
xflm,eoof,ypvmvttcfahfnjvsmjkfnempolpuugosnypuhfsdjbbomidbldiammeohetjnuienvrefrpvsnbtitbppkAA == 3 B== 2 C== 8 v1== 90 tup[v1]== 23
t
a元组的容量超了,内存溢出,说明全部数据正确A == 3 B== 2 C== 8 v1== 90 tup[v1] 23
xemm,dpoe,zpunvsucebheojutmilfmfmoplovufpsmzptifrejacoljdamdhbmlfogftiouhfnuseesputnauiscpolAA == 3 B== 2 C== 9 v1== 90 tup[v1]== 23
t
a元组的容量超了,内存溢出,说明全部数据正确A == 3 B== 2 C== 9 v1== 90 tup[v1] 23
xelm,dooe,ypumvstceahenjusmikfmemoolouufosmypthfrdjabolidaldhamleogetinuhenureerpusnatisbpokAA == 4 B== 1 C== 8 v1== 90 tup[v1]== 23
s
a元组的容量超了,内存溢出,说明全部数据正确A == 4 B== 1 C== 8 v1== 90 tup[v1] 23
wfml,epnf,zovnutubfbgfoivtljlenflppkpvtgprnzouieseibcnmjcbmciblmfnhfsjotifmvsdfsovtmbuhtcoplAA == 4 B== 1 C== 9 v1== 90 tup[v1]== 23
s
a元组的容量超了,内存溢出,说明全部数据正确A == 4 B== 1 C== 9 v1== 90 tup[v1] 23
wfll,eonf,yovmuttbfagfnivsljkenelpokputgornyouhesdibbnmicblcialmenhesjntiemvrdfrovsmbthtbopkAA == 4 B== 2 C== 8 v1== 90 tup[v1]== 23
s
a元组的容量超了,内存溢出,说明全部数据正确A == 4 B== 2 C== 8 v1== 90 tup[v1] 23
weml,dpne,zounusubebgeoiutlilemflopkovtfprmzotiereiacnljcamchbllfngfsiothfmusdesoutmauhscoolAA == 4 B== 2 C== 9 v1== 90 tup[v1]== 23
s
a元组的容量超了,内存溢出,说明全部数据正确A == 4 B== 2 C== 9 v1== 90 tup[v1] 23
well,done,youmustbeageniuslikemelookoutformyotherdiabnlicalchallengesinthemurderousmathsbookAA == 5 B== 1 C== 8 v1== 90 tup[v1]== 23
r
a元组的容量超了,内存溢出,说明全部数据正确A == 5 B== 1 C== 8 v1== 90 tup[v1] 23
vfmk,epmf,znvnttuafbffohvtkjldnfkppjpvsgpqnznuidsehbcmmjbbmbibkmfmhfrjosiflvscfsnvtlbugtcnplAA == 5 B== 1 C== 9 v1== 90 tup[v1]== 23
r
a元组的容量超了,内存溢出,说明全部数据正确A == 5 B== 1 C== 9 v1== 90 tup[v1] 23
vflk,eomf,ynvmtttafaffnhvskjkdnekpojpusgoqnynuhdsdhbbmmibblbiakmemherjnsielvrcfrnvslbtgtbnpkAA == 5 B== 2 C== 8 v1== 90 tup[v1]== 23
r
a元组的容量超了,内存溢出,说明全部数据正确A == 5 B== 2 C== 8 v1== 90 tup[v1] 23
vemk,dpme,znuntsuaebfeohutkildmfkopjovsfpqmzntidrehacmljbambhbklfmgfrioshfluscesnutlaugscnolAA == 5 B== 2 C== 9 v1== 90 tup[v1]== 23
r
a元组的容量超了,内存溢出,说明全部数据正确A == 5 B== 2 C== 9 v1== 90 tup[v1] 23
velk,dome,ynumtstaeafenhuskikdmekoojousfoqmynthdrdhabmlibalbhaklemgerinshelurcernuslatgsbnokAA == 6 B== 1 C== 8 v1== 90 tup[v1]== 23
q
a元组的容量超了,内存溢出,说明全部数据正确A == 6 B== 1 C== 8 v1== 90 tup[v1] 23
ufmj,eplf,zmvnstuafbefogvtjjlcnfjppipvrgppnzmuicsegbclmjabmaibjmflhfqjorifkvsbfsmvtkbuftcmplAA == 6 B== 1 C== 9 v1== 90 tup[v1]== 23
q
a元组的容量超了,内存溢出,说明全部数据正确A == 6 B== 1 C== 9 v1== 90 tup[v1] 23
uflj,eolf,ymvmsttafaefngvsjjkcnejpoipurgopnymuhcsdgbblmiablaiajmelheqjnriekvrbfrmvskbtftbmpkAA == 6 B== 2 C== 8 v1== 90 tup[v1]== 23
q
a元组的容量超了,内存溢出,说明全部数据正确A == 6 B== 2 C== 8 v1== 90 tup[v1] 23
uemj,dple,zmunssuaebeeogutjilcmfjopiovrfppmzmticregaclljaamahbjlflgfqiorhfkusbesmutkaufscmolAA == 6 B== 2 C== 9 v1== 90 tup[v1]== 23
q
a元组的容量超了,内存溢出,说明全部数据正确A == 6 B== 2 C== 9 v1== 90 tup[v1] 23
uelj,dole,ymumsstaeaeengusjikcmejooiourfopmymthcrdgablliaalahajlelgeqinrhekurbermuskatfsbmokAA == 7 B== 1 C== 8 v1== 90 tup[v1]== 23
p
a元组的容量超了,内存溢出,说明全部数据正确A == 7 B== 1 C== 8 v1== 90 tup[v1] 23
tfmi,epkf,zlvnrtuzfbdfofvtijlbnfipphpvqgponzluibsefbckmjabmaibimfkhfpjoqifjvsafslvtjbuetclplAA == 7 B== 1 C== 9 v1== 90 tup[v1]== 23
p
a元组的容量超了,内存溢出,说明全部数据正确A == 7 B== 1 C== 9 v1== 90 tup[v1] 23
tfli,eokf,ylvmrttzfadfnfvsijkbneipohpuqgoonyluhbsdfbbkmiablaiaimekhepjnqiejvrafrlvsjbtetblpkAA == 7 B== 2 C== 8 v1== 90 tup[v1]== 23
p
a元组的容量超了,内存溢出,说明全部数据正确A == 7 B== 2 C== 8 v1== 90 tup[v1] 23
temi,dpke,zlunrsuzebdeofutiilbmfiophovqfpomzltibrefackljaamahbilfkgfpioqhfjusaeslutjauesclolAA == 7 B== 2 C== 9 v1== 90 tup[v1]== 23
p
a元组的容量超了,内存溢出,说明全部数据正确A == 7 B== 2 C== 9 v1== 90 tup[v1] 23
teli,doke,ylumrstzeadenfusiikbmeioohouqfoomylthbrdfabkliaalahailekgepinqhejuraerlusjatesblokAA == 8 B== 1 C== 8 v1== 90 tup[v1]== 23
o
a元组的容量超了,内存溢出,说明全部数据正确A == 8 B== 1 C== 8 v1== 90 tup[v1] 23
sfmh,epjf,zkvnqtuyfbcfoevthjlanfhppgpvpgpnnzkuiaseebcjmjzbmzibhmfjhfojopifivsafskvtibudtckplAA == 8 B== 1 C== 9 v1== 90 tup[v1]== 23
o
a元组的容量超了,内存溢出,说明全部数据正确A == 8 B== 1 C== 9 v1== 90 tup[v1] 23
sflh,eojf,ykvmqttyfacfnevshjkanehpogpupgonnykuhasdebbjmizblziahmejheojnpieivrafrkvsibtdtbkpkA == B== C== 9 2 9
curton 2020-2-6 13:48