Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Floyds-triangle/Java/floyds-triangle.java
Normal file
20
Task/Floyds-triangle/Java/floyds-triangle.java
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
public class Floyd {
|
||||
public static void main(String[] args){
|
||||
printTriangle(5);
|
||||
printTriangle(14);
|
||||
}
|
||||
|
||||
private static void printTriangle(int n){
|
||||
System.out.println(n + " rows:");
|
||||
for(int rowNum = 1, printMe = 1, numsPrinted = 0;
|
||||
rowNum <= n; printMe++){
|
||||
int cols = (int)Math.ceil(Math.log10(n*(n-1)/2 + numsPrinted + 2));
|
||||
System.out.printf("%"+cols+"d ", printMe);
|
||||
if(++numsPrinted == rowNum){
|
||||
System.out.println();
|
||||
rowNum++;
|
||||
numsPrinted = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue