#coding=utf- def getbin(a): out = "" # 辗转相除法 ): div = a mod = a % out += str(mod) ): break a = div ] print(getbin()) 输出 参考: https://www.nuoweb.com/scripts/3158.html https://jingyan.baidu.com/article/f0e83a255ca20422e59101f5.html
public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { System.out.println("please input a positive integer: "); int n = sc.nextInt(); getSubInteger(n); System.out.println("========================="
<span style="color:#FF0000;">第一步:把输入的数字转为字符串n.ToString() 第二步:求出字符串的长度即为正整数的位数 第三步:从后向前逆序输出</span> 附代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; //给一个正整数, //要求:一.求它是几位数,二.逆序打印出各位数字. namespa
python遍历一个目录,输出所有文件名 python os模块 os import os def GetFileList(dir, fileList): newDir = dir if os.path.isfile(dir): fileList.append(dir.encode('gbk')) elif os.path.isdir(dir): for s in os.listdir(dir): #如果需要忽略某些文件夹,使用以下代码 #if s == "xxx":