public class TestNumber { public static void main(String[] args) { for (int i = 0; i < 5; i += 2) { for (int j = i * 1 + 1; j <= i + 5; j++) System.out.print(j + " "); System.out.println(); } } }
追问
逗号 ,也要打印出来 每一行最后一个不要逗号
追答
有点意思哦.....
public class TestNumber { public static void main(String[] args) { for (int i = 0; i < 5; i += 2) { for (int j = i * 1 + 1; j <= i + 5; j++) if(j!=(i+5)) System.out.print(j + ","); else System.out.print(j + " "); System.out.println(); } } }