commit
926ed2e10a
@ -52,6 +52,7 @@ public class AnyBaseToAnyBase {
|
||||
}
|
||||
}
|
||||
System.out.println(base2base(n, b1, b2));
|
||||
in.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,7 @@ public class AnytoAny {
|
||||
dec /= db;
|
||||
}
|
||||
System.out.println(dn);
|
||||
scn.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ class DecimalToBinary {
|
||||
n >>= 1;
|
||||
}
|
||||
System.out.println("\tBinary number: " + b);
|
||||
input.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -64,7 +64,6 @@ public class HexToOct {
|
||||
// convert decimal to octal
|
||||
octalnum = decimal2octal(decnum);
|
||||
System.out.println("Number in octal: " + octalnum);
|
||||
|
||||
|
||||
scan.close();
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class HexaDecimalToDecimal {
|
||||
and it returns the decimal form in the variable dec_output.
|
||||
*/
|
||||
System.out.println("Number in Decimal: " + dec_output);
|
||||
|
||||
scan.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ public class OctalToHexadecimal {
|
||||
// Pass the decimla number to function and get converted Hex form of the number
|
||||
String hex = DecimalToHex(decimal);
|
||||
System.out.println("The Hexadecimal equivalant is: " + hex);
|
||||
input.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,7 @@ start vertex, end vertes and weights. Vertices should be labelled with a number
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
sc.close();
|
||||
}
|
||||
/**
|
||||
* @param source Starting vertex
|
||||
|
@ -42,6 +42,7 @@ public class Main {
|
||||
return;
|
||||
}
|
||||
}
|
||||
In.close();
|
||||
}
|
||||
}
|
||||
}
|
@ -309,6 +309,7 @@ public class RedBlackBST {
|
||||
printTreepre(root);
|
||||
break;
|
||||
}
|
||||
scan.close();
|
||||
}
|
||||
|
||||
public void deleteDemo() {
|
||||
|
@ -74,5 +74,6 @@ public class EditDistance {
|
||||
//ans stores the final Edit Distance between the two strings
|
||||
int ans = minDistance(s1, s2);
|
||||
System.out.println("The minimum Edit Distance between \"" + s1 + "\" and \"" + s2 + "\" is " + ans);
|
||||
input.close();
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ public class Fibonacci {
|
||||
System.out.println(fibMemo(n));
|
||||
System.out.println(fibBotUp(n));
|
||||
System.out.println(fibOptimized(n));
|
||||
sc.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@ public class LongestIncreasingSubsequence {
|
||||
}
|
||||
|
||||
System.out.println(LIS(ar));
|
||||
sc.close();
|
||||
}
|
||||
|
||||
private static int upperBound(int[] ar, int l, int r, int key) {
|
||||
|
@ -13,6 +13,7 @@ public class PrimeCheck {
|
||||
} else {
|
||||
System.out.println(n + " is not a prime number");
|
||||
}
|
||||
scanner.close();
|
||||
}
|
||||
|
||||
/***
|
||||
|
@ -53,5 +53,6 @@ public class MinimizingLateness {
|
||||
System.out.println();
|
||||
System.out.println("Output Data : ");
|
||||
System.out.println(lateness);
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ public class PalindromePrime {
|
||||
System.out.println("Enter the quantity of First Palindromic Primes you want");
|
||||
int n = in.nextInt(); // Input of how many first pallindromic prime we want
|
||||
functioning(n); // calling function - functioning
|
||||
in.close();
|
||||
}
|
||||
|
||||
public static boolean prime(int num) { // checking if number is prime or not
|
||||
|
@ -80,5 +80,6 @@ public class Dijkshtra {
|
||||
System.out.print("-1" + " ");
|
||||
}
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
}
|
@ -44,5 +44,6 @@ public class InsertDeleteInArray {
|
||||
}
|
||||
for (i = 0; i < size2 - 1; i++)
|
||||
System.out.println(b[i]);
|
||||
s.close();
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ public class LowestBasePalindrome {
|
||||
}
|
||||
System.out.println(n + " is a palindrome in base " + lowestBasePalindrome(n));
|
||||
System.out.println(base2base(Integer.toString(n), 10, lowestBasePalindrome(n)));
|
||||
in.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,5 +162,6 @@ public class PerlinNoise {
|
||||
|
||||
System.out.println();
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public class PowerOfTwoOrNot {
|
||||
} else {
|
||||
System.out.println("Number is not a power of two");
|
||||
}
|
||||
sc.close();
|
||||
}
|
||||
|
||||
|
||||
@ -32,5 +33,4 @@ public class PowerOfTwoOrNot {
|
||||
public static boolean checkIfPowerOfTwoOrNot(int number) {
|
||||
return number != 0 && ((number & (number - 1)) == 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ public class ReturnSubsequence {
|
||||
for (int i = 0; i < subsequence.length; i++) {
|
||||
System.out.println(subsequence[i]);
|
||||
}
|
||||
s.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,6 +14,8 @@ public class RootPrecision {
|
||||
// P is precision value for eg - P is 3 in 2.564 and 5 in 3.80870.
|
||||
int P = scn.nextInt();
|
||||
System.out.println(squareRoot(N, P));
|
||||
|
||||
scn.close();
|
||||
}
|
||||
|
||||
public static double squareRoot(int N, int P) {
|
||||
|
@ -67,6 +67,7 @@ class Schedule {
|
||||
processes.add(p);
|
||||
burstAll += p.burstTime;
|
||||
}
|
||||
in.close();
|
||||
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ public class StackPostfixNotation {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
String post = scanner.nextLine(); // Takes input with spaces in between eg. "1 21 +"
|
||||
System.out.println(postfixEvaluate(post));
|
||||
scanner.close();
|
||||
}
|
||||
|
||||
// Evaluates the given postfix expression string and returns the result.
|
||||
@ -35,6 +36,7 @@ public class StackPostfixNotation {
|
||||
// "+", "-", "*", "/"
|
||||
}
|
||||
}
|
||||
tokens.close();
|
||||
return s.pop();
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ public class TopKWords {
|
||||
for (int i = 0; i < k; i++) {
|
||||
System.out.println(list.get(list.size() - i - 1));
|
||||
}
|
||||
input.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,5 +22,6 @@ class TowerOfHanoi {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int numberOfDiscs = scanner.nextInt(); //input of number of discs on pole 1
|
||||
shift(numberOfDiscs, "Pole1", "Pole2", "Pole3"); //Shift function called
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
|
@ -126,6 +126,7 @@ public class Caesar {
|
||||
case 'd':
|
||||
System.out.println("DECODED MESSAGE IS \n" + decode(message, shift));
|
||||
}
|
||||
input.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user