Lab 7 - cs.albany.eduwooseok/201Fall/slide/Lab7.pdfLab 7 Wooseok Kim wkim3@albany.edu wooseok/201
Post on 25-Oct-2019
3 Views
Preview:
Transcript
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
# of empty space
1 2 3 4 5 6 7 8 9 10
# of empty space
1
1 2 3 4 5 6 7 8 9 10
# of empty space
1
2
1 2 3 4 5 6 7 8 9 10
# of empty space
1
2
3
1 2 3 4 5 6 7 8 9 10
# of empty space
1
2
3
4
1 2 3 4 5 6 7 8 9 10
# of empty space
1
2
3
4
5
1 2 3 4 5 6 7 8 9 10
# of empty space
1 2 3 4 5 6 7 8 9 10
# of empty space
5
1 2 3 4 5 6 7 8 9 10
# of empty space
5
4
1 2 3 4 5 6 7 8 9 10
# of empty space
5
4
3
1 2 3 4 5 6 7 8 9 10
# of empty space
5
4
3
2
1 2 3 4 5 6 7 8 9 10
# of empty space
5
4
3
2
1
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
Total # of *
1
2
3
4
5
6
7
8
9
9
Total # of *
1
2
3
4
5
6
7
8
9
9
7
Total # of *
1
2
3
4
5
6
7
8
9
9
7
5
Total # of *
1
2
3
4
5
6
7
8
9
9
7
5
3
Total # of *
1
2
3
4
5
6
7
8
9
9
7
5
3
1
Total # of *
1
2
3
4
5
6
7
8
9
9
7
5
3
1
3
Total # of *
1
2
3
4
5
6
7
8
9
9
7
5
3
1
3
5
Total # of *
1
2
3
4
5
6
7
8
9
9
7
5
3
1
3
5
7
Total # of *
1
2
3
4
5
6
7
8
9
9
7
5
3
1
3
5
7
9
Total # of *
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1
2
3
4
5
6
7
8
9
10
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2
3
4
5
6
7
8
9
10
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3
4
5
6
7
8
9
10
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4
5
6
7
8
9
10
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5
6
7
8
9
10
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5 * 5 1
6
7
8
9
10
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5 * 5 1
6 * 5 1
7
8
9
10
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5 * 5 1
6 * 5 1
7 * * * 4 3
8
9
10
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5 * 5 1
6 * 5 1
7 * * * 4 3
8 * * * * * 3 5
9
10
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5 * 5 1
6 * 5 1
7 * * * 4 3
8 * * * * * 3 5
9 * * * * * * * 2 7
10
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5 * 5 1
6 * 5 1
7 * * * 4 3
8 * * * * * 3 5
9 * * * * * * * 2 7
10 * * * * * * * * * 1 9
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5 * 5 1
6 * 5 1
7 * * * 4 3
8 * * * * * 3 5
9 * * * * * * * 2 7
10 * * * * * * * * * 1 9
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5 * 5 1
1 * 5 1
2 * * * 4 3
3 * * * * * 3 5
4 * * * * * * * 2 7
5 * * * * * * * * * 1 9
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5 * 5 1
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5 * 5 1
The Number of rows (height): 5
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5 * 5 1
The Number of rows (height): 5
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5 * 5 1
The Number of rows (height): 5 Create a table of 5 rows!
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * * * * * * * * * 1 9
2 * * * * * * * 2 7
3 * * * * * 3 5
4 * * * 4 3
5 * 5 1
The Number of rows (height): 5 Create a table of 5 rows!
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
The Number of rows (height): 5 Create a table of 5 rows!
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make an empty triangle within the table! Create a table of 5 rows!
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make an empty triangle within the table!• Row 5 – 1• Row 4 – 2• Row 3 – 3• Row 2 – 4• Row 1 – 5
Create a table of 5 rows!
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make an empty triangle within the table!• Row 5 – 1 == (6 – 5)• Row 4 – 2 == (6 – 4)• Row 3 – 3 == (6 – 3)• Row 2 – 4 == (6 – 2)• Row 1 – 5 == (6 – 1)
Create a table of 5 rows!
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make an empty triangle within the table!• Row 5 – 1 == (6 – 5) = (5+1 – 5)• Row 4 – 2 == (6 – 4) = (5+1 – 4)• Row 3 – 3 == (6 – 3) = (5+1 – 3)• Row 2 – 4 == (6 – 2) = (5+1 – 2)• Row 1 – 5 == (6 – 1) = (5+1 – 1)
Create a table of 5 rows!
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make an empty triangle within the table!• Row 5 – 1 == (6 – 5) = (5+1 – 5) = (row+1 – i)• Row 4 – 2 == (6 – 4) = (5+1 – 4) = (row+1 – i)• Row 3 – 3 == (6 – 3) = (5+1 – 3) = (row+1 – i)• Row 2 – 4 == (6 – 2) = (5+1 – 2) = (row+1 – i)• Row 1 – 5 == (6 – 1) = (5+1 – 1) = (row+1 – i)
Create a table of 5 rows!
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make an empty triangle within the table!• Row 5 – 1 == (6 – 5) = (5+1 – 5) = (row+1 – i)• Row 4 – 2 == (6 – 4) = (5+1 – 4) = (row+1 – i)• Row 3 – 3 == (6 – 3) = (5+1 – 3) = (row+1 – i)• Row 2 – 4 == (6 – 2) = (5+1 – 2) = (row+1 – i)• Row 1 – 5 == (6 – 1) = (5+1 – 1) = (row+1 – i)
Create a table of 5 rows!
The Number of rows (height): 5
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make an empty triangle within the table!• Row 5 – 1 == (6 – 5) = (5+1 – 5) = (row+1 – i)• Row 4 – 2 == (6 – 4) = (5+1 – 4) = (row+1 – i)• Row 3 – 3 == (6 – 3) = (5+1 – 3) = (row+1 – i)• Row 2 – 4 == (6 – 2) = (5+1 – 2) = (row+1 – i)• Row 1 – 5 == (6 – 1) = (5+1 – 1) = (row+1 – i)
Create a table of 5 rows!
The Number of rows (height): 5
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make an empty triangle within the table!• Row 5 – 1• Row 4 – 2• Row 3 – 3• Row 2 – 4• Row 1 – 5
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5
Make an empty triangle within the table!• Row 5
• for(j=5+1-5; j>=1; --j)• System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
Make an empty triangle within the table!• Row 5
• for(j=1; j>=1; --j)• System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
Make an empty triangle within the table!• Row 5
• for(j=1; j>=1; --j)• System.out.print(“*”);
• System.out.println();
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
4
Make an empty triangle within the table!• Row 4
• for(j=5+1-4; j>=1; --j)• System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
4 * *
Make an empty triangle within the table!• Row 4
• for(j=2; j>=1; --j)• System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
4 * *
Make an empty triangle within the table!• Row 4
• for(j=2; j>=1; --j)• System.out.print(“*”);
• System.out.println();
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
4 * *
3
Make an empty triangle within the table!• Row 3
• for(j=5+1-3; j>=3; --j)• System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
4 * *
3 * * *
Make an empty triangle within the table!• Row 3
• for(j=3; j>=1; --j)• System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
4 * *
3 * * *
Make an empty triangle within the table!• Row 3
• for(i=1; i<=3; ++i)• System.out.print(“*”);
• System.out.println();
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
4 * *
3 * * *
2
Make an empty triangle within the table!• Row 2
• for(j=5+1-2; j>=1; --j)• System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
4 * *
3 * * *
2 * * * *
Make an empty triangle within the table!• Row 2
• for(j=4; j>=1; --j)• System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
4 * *
3 * * *
2 * * * *
Make an empty triangle within the table!• Row 2
• for(j=4; j>=1; --j)• System.out.print(“*”);
• System.out.println();
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
4 * *
3 * * *
2 * * * *
1
Make an empty triangle within the table!• Row 1
• for(j=5+1-1; j>=1; ==j)• System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
4 * *
3 * * *
2 * * * *
1 * * * * *
Make an empty triangle within the table!• Row 1
• for(j=5; j>=5; --j)• System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
4 * *
3 * * *
2 * * * *
1 * * * * *
Make an empty triangle within the table!• Row 1
• for(j=5; j>=5; --j)• System.out.print(“*”);
• System.out.println();
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 *
4 * *
3 * * *
2 * * * *
1 * * * * *
Make an empty triangle within the table!• Row 1
• for(j=5; j>=5; --j)• System.out.print(“*”);
• System.out.println();
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make an empty triangle within the table!
• Row 1• for(j=5; j>=5; --j)
• System.out.print(“*”);• System.out.println();
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make a triangle within the table!
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make a triangle within the table!• Row 5 – 9• Row 4 – 7• Row 3 – 5• Row 2 – 3• Row 1 – 1
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make a triangle within the table!• Row 5 – 9 = (5*2) - 1• Row 4 – 7 = (4*2) - 1• Row 3 – 5 = (3*2) - 1• Row 2 – 3 = (2*2) - 1• Row 1 – 1 = (1*2) - 1
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make a triangle within the table!• Row 5 – 9 = (5*2) - 1• Row 4 – 7 = (4*2) - 1• Row 3 – 5 = (3*2) - 1• Row 2 – 3 = (2*2) - 1• Row 1 – 1 = (1*2) - 1
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make a triangle within the table!• Row 5 – 9 = (5*2) – 1 = (i*2) -1• Row 4 – 7 = (4*2) – 1 = (i*2) -1• Row 3 – 5 = (3*2) – 1 = (i*2) -1• Row 2 – 3 = (2*2) – 1 = (i*2) -1• Row 1 – 1 = (1*2) – 1 = (i*2) -1
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 1
Make a triangle within the table!• Row 5
• for(j=1; j>=1; --j)• System.out.print(“ ”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 1
Make a triangle within the table!• Row 5
• for(j=1; j>=1; --j)• System.out.print(“ ”);
• for(k=5*2-1; k>=1; --k) • System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
Make a triangle within the table!• Row 5
• for(j=1; j>=1; --j)• System.out.print(“ ”);
• for(k=9; k>=1; --k) • System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 2
Make a triangle within the table!• Row 4
• for(j=2; j>=1; --j)• System.out.print(“ ”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 2
Make a triangle within the table!• Row 4
• for(j=2; j>=1; --j)• System.out.print(“ ”);
• for(k=4*2-1; k>=1; --k) • System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
Make a triangle within the table!• Row 4
• for(j=2; j>=1; --j)• System.out.print(“ ”);
• for(k=7; k>=1; --k) • System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3
Make a triangle within the table!• Row 3
• for(j=3; j>=1; --j)• System.out.print(“ ”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 3
Make a triangle within the table!• Row 3
• for(j=3; j>=1; --j)• System.out.print(“ ”);
• for(k=3*2-1; k>=1; --k) • System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
Make a triangle within the table!• Row 3
• for(j=3; j>=1; --j)• System.out.print(“ ”);
• for(k=5; k>=1; --k) • System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 4
Make a triangle within the table!• Row 2
• for(j=4; j>=1; --j)• System.out.print(“ ”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 4
Make a triangle within the table!• Row 2
• for(j=4; j>=1; --j)• System.out.print(“ ”);
• for(k=2*2-1; k>=1; --k) • System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
Make a triangle within the table!• Row 2
• for(j=4; j>=1; --j)• System.out.print(“ ”);
• for(k=3; k>=1; --k) • System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1
Make a triangle within the table!• Row 1
• for(j=5; j>=1; --j)• System.out.print(“ ”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 5
Make a triangle within the table!• Row 1
• for(j=5; j>=1; --j)• System.out.print(“ ”);
• for(k=1*2-1; k>=1; --k) • System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make a triangle within the table!• Row 1
• for(j=5; j>=1; --j)• System.out.print(“ ”);
• for(k=1; k>=1; --k) • System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
Make a triangle within the table!• Row 1
• for(j=5; j>=1; --j)• System.out.print(“ ”);
• for(k=1; k>=1; --k) • System.out.print(“*”);
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
1 * 5 1
2 * * * 4 3
3 * * * * * 3 5
4 * * * * * * * 2 7
5 * * * * * * * * * 1 9
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
1 * 5 1
2 * * * 4 3
3 * * * * * 3 5
4 * * * * * * * 2 7
5 * * * * * * * * * 1 9
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
1 * 5 1
2 * * * 4 3
3 * * * * * 3 5
4 * * * * * * * 2 7
5 * * * * * * * * * 1 9
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
1 * 5 1
2 * * * 4 3
3 * * * * * 3 5
4 * * * * * * * 2 7
5 * * * * * * * * * 1 9
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
5 * * * * * * * * * 1 9
4 * * * * * * * 2 7
3 * * * * * 3 5
2 * * * 4 3
1 * 5 1
1 * 5 1
2 * * * 4 3
3 * * * * * 3 5
4 * * * * * * * 2 7
5 * * * * * * * * * 1 9
• Row 5 -> Row 1• Row 4 -> Row 2• Row 3 -> Row 3• Row 2 -> Row 4• Row 1 -> Row 5
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * 5 1
2 * * * 4 3
3 * * * * * 3 5
4 * * * * * * * 2 7
5 * * * * * * * * * 1 9
Create a table of 5 rows!
• Row 5 • Row 4 • Row 3 • Row 2 • Row 1
Create a table of 5 rows!
• Row 1• Row 2 • Row 3 • Row 4 • Row 5
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * 5 1
2 * * * 4 3
3 * * * * * 3 5
4 * * * * * * * 2 7
5 * * * * * * * * * 1 9
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * 5 1
2 * * * 4 3
3 * * * * * 3 5
4 * * * * * * * 2 7
5 * * * * * * * * * 1 9
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * 5 1
2 * * * 4 3
3 * * * * * 3 5
4 * * * * * * * 2 7
5 * * * * * * * * * 1 9
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * 5 1
2 * * * 4 3
3 * * * * * 3 5
4 * * * * * * * 2 7
5 * * * * * * * * * 1 9
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * 5 1
2 * * * 4 3
3 * * * * * 3 5
4 * * * * * * * 2 7
5 * * * * * * * * * 1 9
1 2 3 4 5 6 7 8 9 10 Total “ ” Total *
1 * 5 1
2 * * * 4 3
3 * * * * * 3 5
4 * * * * * * * 2 7
5 * * * * * * * * * 1 9
The Number of rows (height): 5 The Number of rows (height): 1~5
The Number of rows (height): 5 For input, Use the Scanner or JOptionPane
Use While loop in order to keep trying the input
Use While loop in order to keep trying the input
Can’t escape from the While loop if row value isn’t 1~5
Use While loop in order to keep trying the input
top related