public class ForDemo3 {
public static void main(String[] args) {
//用for或while循环输出1-1000之间能被5整除的数,并且每行输出3个
for (int i = 1; i <= 1000; i++) {
if (i%5==0){
System.out.print(i+"\t"); // \t代表空格
}
if (i%15==0){
System.out.println();
}
}
}
}
public class ForDemo4 {
//用for循环打印九九乘法表
public static void main(String[] args) {
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= i; j++) { //第二个for语句执行完成时,第一个for才继续进行
System.out.print(i+"*"+j+"="+(i*j)+"\t");
}
System.out.println();
}
}
}
public class TextDemo {
public static void main(String[] args) {
//打印三角形
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();
}
}
}
public class ForDemo3 { public static void main(String[] args) { //用for或while循环输出1-1000之间能被5整除的数,并且每行输出3个 for (int i = 1; i <= 1000; i++) { if (i%5==0){ System.out.print(i+"\t"); // \t代表空格 ...