[Algorithms] multiplication table
python
#!/usr/bin/envpython#encoding=utf-8#Date:2016-08-25#Author:Eric.zhangtj@homecredit.cn#Purpose:JustforfunTableLenth=int(raw_input("InputtheMaxlinesyouwant:\n"))foriinrange(1,TableLenth+1):forjinrange(1,i+1):result=i*jprint"%s*%s=%s\t"%(i,j,result),print"\n"
shell
#!/bin/bash#encoding=utf-8#Date:2016-08-25#Author:Eric.zhangtj@homecredit.cn#Purpose:Justforfunread-p"InputtheMaxlinesyouwant:"TableLenthforiin$(seq1$TableLenth)doforjin$(seq1$i)doresult=$[$i*$j]echo-n-e"$i+$j=$result\t"doneecho-e"\n"done
C
java
classMultiTable{publicstaticvoidmain(String[]args){inti,j;for(i=1;i<=9;i++){for(j=1;j<=i;j++){System.out.print(i+"*"+j+"="+i*j+"\t");}System.out.print("\n");}}}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。