mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-10 21:43:15 +08:00
Merge pull request #365 from JeonSeongBae/SeongBaeJeon1
Add line that closing scanner
This commit is contained in:
@ -9,7 +9,7 @@ public class FibToN {
|
|||||||
// print fibonacci sequence less than N
|
// print fibonacci sequence less than N
|
||||||
int first = 0, second = 1;
|
int first = 0, second = 1;
|
||||||
//first fibo and second fibonacci are 0 and 1 respectively
|
//first fibo and second fibonacci are 0 and 1 respectively
|
||||||
|
scn.close();
|
||||||
while(first <= N){
|
while(first <= N){
|
||||||
//print first fibo 0 then add second fibo into it while updating second as well
|
//print first fibo 0 then add second fibo into it while updating second as well
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ class FloydTriangle {
|
|||||||
Scanner sc = new Scanner(System.in);
|
Scanner sc = new Scanner(System.in);
|
||||||
System.out.println("Enter the number of rows which you want in your Floyd Triangle: ");
|
System.out.println("Enter the number of rows which you want in your Floyd Triangle: ");
|
||||||
int r = sc.nextInt(), n = 0;
|
int r = sc.nextInt(), n = 0;
|
||||||
|
sc.close();
|
||||||
for(int i=0; i < r; i++) {
|
for(int i=0; i < r; i++) {
|
||||||
for(int j=0; j <= i; j++) {
|
for(int j=0; j <= i; j++) {
|
||||||
System.out.print(++n + " ");
|
System.out.print(++n + " ");
|
||||||
|
Reference in New Issue
Block a user