-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Raven-Lee/feature
Feature
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
public class Main { | ||
|
||
public static void main(String[] args) { | ||
|
||
Triangle triangle1 = new Triangle(); | ||
|
||
triangle1.isoscelesTriangle(); | ||
triangle1.asteriskTriangle(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# Hello-world | ||
This is my first repository | ||
I am trying to learn Java on imooc.com. | ||
The exercise code will be putted on this repository. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Created by Administrator on 2017/6/1. | ||
* Creating a isosceles triangle with number | ||
*/ | ||
|
||
public class Triangle { | ||
|
||
public void isoscelesTriangle() { | ||
for (int i = 1; i < 10; i++) { | ||
for (int j = 9; j > i; j--) { | ||
System.out.print(" ");//for empty space in front of number which make | ||
} | ||
for (int k = i; k >= 1; k--) { | ||
System.out.print(k);//numbers before 1 | ||
} | ||
for (int l = 2; l <= i; l++) { | ||
System.out.print(l);//numbers after 1 | ||
} | ||
System.out.println(""); | ||
} | ||
System.out.println(""); | ||
} | ||
|
||
public void asteriskTriangle() { | ||
for (int i = 1; i < 10; i++) { | ||
for (int j = 9; j > i; j--) { | ||
System.out.print(" ");//for empty space in front of number which make | ||
} | ||
for (int k = i; k >= 1; k--) { | ||
System.out.print("*");//numbers before 1 | ||
} | ||
for (int l = 2; l <= i; l++) { | ||
System.out.print("*");//numbers after 1 | ||
} | ||
System.out.println(""); | ||
} | ||
} | ||
|
||
|
||
} |