方法一: 1 #!/bin/bash 2 for a in {1..9};do 3 for b in {1..9};do 4 c=`echo "$a*$b" |bc` 5 if [ "$a" -ge "$b" ];then 6 echo -n -e "$b*$a=$c\t" 7 fi 8 done 9 echo 10 done 方法二: 1 #!/bin/bash 2 for a in `seq 1 9`;do 3 for b
一.矩形 #******输入行和列,打印相应的矩形******# width = input("宽:") longth = input("长:") if (width.isdigit() & longth.isdigit()): #确定输入的为整数 #该循环用来控制宽,即列的行数 for j in range(int(width)): #range创建整数列表,里面要用int,input返回的是str #该循环用来控制长,即长的列数 for i in ran
一.99乘法表 for i in range(1, 10): for j in range(1, i + 1): print('%sx%s=%s ' % (j, i, j * i), end='') print() 二.由用户指定相乘到多少 import sys if len(sys.argv) != 2: print('请输入要生成乘法表要相乘到多少!') exit(5) for i in range(1, int(sys.argv[1])+1): for j in range(1, i +
Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number quickly from the multiplication table? Given the height m and the length n of a m * n Multiplication Table, and a positive integer k, you need to ret
Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number quickly from the multiplication table? Given the height m and the length n of a m * nMultiplication Table, and a positive integer k, you need to retu