while i >0:k += m[i-1]* t # t記錄某一位置對應的權值t *=10i -=1
4.確定程序框架
程序的流程圖如圖所示。
5.完整的程序
%%time
# 回文數if __name__ =='__main__':m =[1]*17count =0print("No. number it's square(palindrome)")for n inrange(1,256):# 窮舉n的取值范圍k, i, t, a =0,0,1, n*n # 計算n的平方squ = awhile a !=0:# 從低到高分解數a的每一位存于數組m[1]~m[16]m[i]= a %10a //=10i +=1while i >0:k += m[i-1]* t # t記錄某一位置對應的權值t *=10i -=1if k == squ:count +=1print("%2d%10d%10d"%(count, n, n*n))
No. number it's square(palindrome)1 1 12 2 43 3 94 11 1215 22 4846 26 6767 101 102018 111 123219 121 14641
10 202 40804
11 212 44944
CPU times: user 2.72 ms, sys: 0 ns, total: 2.72 ms
Wall time: 1.99 ms
%%time
# 回文數判斷if __name__ =='__main__':x =int(input("請輸入一個5位數整數:"))if x <10000or x >99999:print("輸入錯誤")else:ten_thousand = x //10000#拆分最高位萬位thousand = x %10000//1000#拆分千位ten = x %100//10#拆分十位indiv = x %10#拆分個位if indiv == ten_thousand and ten == thousand:print("%d是回文數"%x)else:print("%d不是回文數"%x)
12321是回文數
CPU times: user 60.4 ms, sys: 11.3 ms, total: 71.7 ms
Wall time: 5.86 s
達夢數據庫基礎操作(一):用戶操作
1 達夢運行狀態
SELECT banner as 版本信息 FROM v$version;1.2 達夢版本號
SELECT banner as 版本信息 FROM v$version;1.3 用戶相關操作
默認用戶名密碼:SYSDBA/SYSDBA
注意:在哪個數據庫下創建的用戶…