Print special multiplication table (java)

Print a special multiplication table: do not print when it encounters a multiple of 12; wrap when it encounters a multiple of 28.

(You can also set the conditions yourself and output the multiplication table that meets the conditions. The set conditions are explained in the form of comments in the code, and the program is given in the source program)

【code show as below】:

public class TimesTable{
  public static void main(String[] args){
    for(int i=1;i<=9;i++){
      for(int j=i;j<=9;j++){
         if((i*j)%12!=0){
           System.out.print(i+"*"+j+"="+i*j+" ");
          }
         if((i*j)%28==0){
           System.out.println();//换行
          }
        //System.out.print(i+"*"+j+"="+i*j+" ");
      }
    System.out.println();//换行
    }
  }
}

Guess you like

Origin blog.csdn.net/ZQY211210400628/article/details/129339133