Java每日一题03
输出:
02 A 04 A 06 A 08 A 10 A;
12 A 14 A 16 A 18 A 20 A;
22 A 24 A 26 A 28 A 30 A;
32 A 34 A 36 A 38 A 40 A;
42 A 44 A 46 A 48 A 50 A;
重点1:数字的格式:02,04
重点2:如果不是这道题,已经忘记除了i++以外的写法了:(
package test09;import java.text.DecimalFormat;import java.text.NumberFormat;public class PrintA {/** * @param args */public static void main(String[] args) {DecimalFormat df = (DecimalFormat) NumberFormat.getInstance();df.applyPattern("00");// TODO Auto-generated method stubfor (int i = 2; i <= 50; i += 2) {if (i % 10 == 0) {System.out.println(" " + df.format(i) + " A;");} else {System.out.print(" " + df.format(i) + " A");}}}}# public class PrintA { # # /** # * @param args # */ # public static void main(String[] args) { # # DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(); # df.applyPattern("00"); # # // TODO Auto-generated method stub # for (int i = 2; i <= 50; i += 2) { # System.out.print(" " + df.format(i) + " A;"); # if (i % 10 == 0) { System.out.println();# } # } # } # } UPpublic class PrintA {public static void main(String[] args){for(int i = 0;i < 5;i++){int last = i+1;System.out.println(i+"2 "+"A "+i+"4 "+"A "+i+"6 "+"A "+i+"8 "+"A "+last+"0 "+"A");}}}