99乘法表 java for循环
public static void main(String[] args) { //0-100的奇数和偶数和 int jsum=0; int osum=0; for (int i = 0; i < 100; i++) { if (i%2!=0) { jsum += i; }else{ osum+=i; } } System.out.println("奇数和:"+jsum); System.out.println("偶数和:"+osum); System.out.println("============================"); //能被5整除 输出形式3行 for (int i = 0; i < 1000; i++) { if (i%5==0){ System.out.print(i+"\t"); } if (i%(5*3)==0){//每行 System.out.println(); } //System.out.println(); 会换行 // System.out.print();不换行 } System.out.println("\n"+"=========================="); //打印99乘法表 for (int j = 1; j<= 9; j++) { for (int i = 1; i <= j; i++) { System.out.print(j+"*"+i+"="+(j*i)+"\t");//不换行 } System.out.println();//换行 } System.out.println("\n"+"=========================="); int num=0; while (num<100){ num++; if (num%10==0){//是10的倍数 System.out.println(); continue;//跳出本次循环 } System.out.print(num); } System.out.println("\n"+"=========================="); //打印三角形 for (int i =1; i <=5; i++) { //先打印空白的地方 for (int j =5;j>=i;j--){ System.out.print(" ");//不换行 } //左边的小星星 for (int j =1;j<=i;j++){ System.out.print("*");//不换行 } //右边的小星星 for (int j =1;j<i;j++){ System.out.print("*");//不换行 } System.out.println(); } System.out.println("\n"+"=========================="); }