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TEBAWRLWDWNHHNNNWQNIIBUCGUJYMRYW
CZDKISKUSBPFHVGSAVJBDMNPSDKFRXVVPLVAQUGVUJEXSZFGFQ
IYIJGISUANRAXTGQLAVFMQTICKQAHLEBGHAVOVVPEXIMLFWIYI
ZIIFSOPCMAWCBPKWZBUQPQLGSNIBFADUUJJHPAIUVVNWNWKDZB
HGTEEIISFGIUEUOWXVTPJDVACYQYFQUCXOXOSSMXLZDQESHXKP
FEBZHJAGIFGXSMRDKGONGELOALLSYDVILRWAPXXBPOOSWZNEAS
VJGMAOFLGYIFLJTEKDNIWHJAABCASFMAKIENSYIZZSLRSUIPCJ
BMQGMPDRCPGWKTPLOTAINXZAAJWCPUJHPOUYWNWHZAKCDMZDSR
RRARTVHZYYCEDXJQNQAINQVDJCZCZLCQWQQIKUYMYMOVMNCBVY
ABTCRRUXVGYLZILFLOFYVWFFBZNFWDZOADRDCLIRFKBFBHMAXX
解题过程
作为一个小菜鸡,真是辛苦得一批
#递增序列
l=[]
#数据有30行
for i in range(30):
l1=input()
l.append(l1)
count=0
for i in range(len(l)):
for j in range(len(l[i])):
#第一个循环,寻找同行
for m in range(j,len(l[i])):
if l[i][j]<l[i][m]:
print(l[i][j]+l[i][m])
count+=1
#第二个循环,寻找同一列
for m in range(i, len(l)):
if l[i][j]<l[m][j]:
print(l[i][j]+l[m][j])
count+=1
#第三个循环,寻找-45度的数,防止数组越界,所以使用异常检测
for m in range(1,100):
try:
if l[i][j]<l[i+m][j+m]:
print(l[i][j]+l[i+m][j+m])
count+=1
except:
break
#第四个循环,找到45度的数
for m in range(1,100):
try:
#这里有个坑,Python数组下标可以为负数
#括号一定要打,一开始我没有打就出错了
if (l[i][j]<l[i-m][j+m] or l[i][j]>l[i-m][j+m] )and i-m>=0:
print(l[i][j]+l[i-m][j+m])
count+=1
except:
break
print(count)
本文来自博客园,作者:{Zeker62},转载请注明原文链接:https://www.cnblogs.com/Zeker62/p/15046256.html