def printLine(row): for col in range(1,row+1): print("{}*{}={}\t".format(col,row,col*row),end=" ") #\t为转义字符,横向制表符,end=" "为实现分段 print("") for row in range(1,10): printLine(row) #实现换行 1*1=1 1*2=2 2*2=4 1*3=3 2*3=6 3*3
利用for循环制作简单的99乘法表 public class chengfabiao { public static void main(String[] args) { for(int a = 1;a <= 9;a++) { for(int b = 1; b <= a;b++) { int res = a * b; System.out.print("["+a+"x"+b+"="+res+"]"); } Syst
1.实例:输出12个星座符号,以反斜线分隔 for i in range(9800,9812): print(chr(i),end='\\') 2.实例:恺撒密码的编码 s = input("请输入凯撒的明文密码:") 2 for i in s: 3 if ord("a") <= ord(i) <= ord("z"): 4 print(chr(ord("a") + (ord(i) - ord("a&q
import org.junit.Test; public class Multiple { public void printMultiple99() { int i = 1; for (; i < 10; i++) for (int j = 1; j <= i; j++) System.out.print(j + "*" + i + "=" + i * j + " "); System.out.println(); } @Test
1 实例:输出12个星座符号,以反斜线分隔. for i in range(12): print(chr(9800+i),end='\\') 2 实例:恺撒密码的编码. plaincode=input('明文:') print('密文:',end='') s=ord('a') t=ord('z') for i in plaincode: if s<= ord(i)<=t: print(chr(s+(ord(i)-s+3)%26),end='') else: print(i,end='') 3