public class ForFor99Demo {
public static void main(String[] args) {
//九九乘法表
for(int x=1;x<=9;x++) {
for(int y=1;y<=x;y++) {
System.out.print(y+"x"+x+"="+x*y+"\t");
}
System.out.println();
}
// System.out.println("\\Hellow\tWorld\\");
/*
* \n 回车键;
* \t 制表符;
* \b 退格;
* \r 按下回车键
*/
}
}
public class ForForDemo {
public static void main(String[] args) {
/*
*****
*****
*****
*****
*/
//
// for(int x=0;x<4;x++) { //外循环控制的是次数
// for(int y=0;y<5;y++) { //内循环控制的是每一行的个数
// System.out.print("*");
// }
// System.out.println();
// }
//
for(int a=0;a<4;a++) {
for(int b=0;b<5;b++) {
System.out.print("*");
}
System.out.println();
}
}
}
public class ForForTest {
public static void main(String[] args) {
/*
*****
****
***
**
*
*/
/*
int z = 5 ;
for(int x=1;x<=5;x++) {
for(int y=1;y<=z;y++) { //1-5 1-4 1-3 1-2
System.out.print("*");
}
System.out.println();
z-- ;
}
*/
/*
int z = 1 ;
for(int x=1;x<=5;x++) {
for(int y=z;y<=5;y++) { //1-5 2-5 3-5 4-5
System.out.print("*");
}
System.out.println();
z++ ;
}
*/
/*
for(int x=5;x>=1;x--) {
for(int y=1;y<=x;y++) { //1-5 2-5 3-5 4-5
System.out.print("*");
}
System.out.println();
}
*/
for(int x=1;x<=5;x++) {
for(int y=x;y<=5;y++) { //1-5 2-5 3-5 4-5
System.out.print("*");
}
System.out.println();
}
}
}
public class ForForTest2 {
public static void main(String[] args) {
/*
*
**
***
****
*****
*/
for(int x=1;x<=5;x++) {
for(int y=1;y<=x;y++) {
System.out.print("*");
}
System.out.println();
}
System.out.println("------------------------------");
/*
* 54321
* 5432
* 543
* 54
* 5
*/
for(int x=1;x<=5;x++) {
for(int y=5;y>=x;y--) {
System.out.print(y);
}
System.out.println();
}
System.out.println("------------------------------");
/*
* 1
* 22
* 333
* 4444
* 55555
*/
for(int x=1;x<=5;x++) {
for(int y=1;y<=x;y++) {
System.out.print(x);
}
System.out.println();
}
}
}
public class ForForTest3 {
public static void main(String[] args) {
/*
* * * * *
-* * * *
--* * *
---* *
----*
*/
for(int x=1;x<=5;x++) {
for(int y=1;y<x;y++) {
System.out.print(" ");
}
for(int z=x;z<=5;z++) {
System.out.print("* ");
}
System.out.println();
}
System.out.println("--------------------------------------");
/*
----*
---* *
--* * *
-* * * *
* * * * *
*/
for(int x=1;x<=5;x++) {
for(int y=4;y>=x;y--) {
System.out.print(" ");
}
for(int z=1;z<=x;z++) {
System.out.print("* ");
}
System.out.println();
}
}
}
ForForDemo
最新推荐文章于 2021-12-22 12:00:00 发布