mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-24 04:54:21 +08:00
style: enable MultipleVariableDeclarations
in checkstyle (#5175)
Co-authored-by: vaibhav <vaibhav.waghmare@techprescient.com>
This commit is contained in:
@ -113,7 +113,8 @@ public final class BankersAlgorithm {
|
||||
* This is main method of Banker's Algorithm
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
int numberOfProcesses, numberOfResources;
|
||||
int numberOfProcesses;
|
||||
int numberOfResources;
|
||||
|
||||
Scanner sc = new Scanner(System.in);
|
||||
|
||||
|
@ -63,7 +63,8 @@ class Graph {
|
||||
*/
|
||||
public static class Edge {
|
||||
|
||||
public final String v1, v2;
|
||||
public final String v1;
|
||||
public final String v2;
|
||||
public final int dist;
|
||||
|
||||
Edge(String v1, String v2, int dist) {
|
||||
@ -198,7 +199,8 @@ class Graph {
|
||||
* Implementation of dijkstra's algorithm using a binary heap.
|
||||
*/
|
||||
private void dijkstra(final NavigableSet<Vertex> q) {
|
||||
Vertex u, v;
|
||||
Vertex u;
|
||||
Vertex v;
|
||||
while (!q.isEmpty()) {
|
||||
// vertex with shortest distance (first iteration will return source)
|
||||
u = q.pollFirst();
|
||||
|
@ -23,7 +23,8 @@ public final class FibbonaciSeries {
|
||||
// Get input from the user
|
||||
Scanner scan = new Scanner(System.in);
|
||||
int n = scan.nextInt();
|
||||
int first = 0, second = 1;
|
||||
int first = 0;
|
||||
int second = 1;
|
||||
scan.close();
|
||||
while (first <= n) {
|
||||
// print first fibo 0 then add second fibo into it while updating second as well
|
||||
|
@ -9,7 +9,8 @@ final class FloydTriangle {
|
||||
public static void main(String[] args) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
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();
|
||||
int n = 0;
|
||||
sc.close();
|
||||
for (int i = 0; i < r; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
|
@ -21,7 +21,10 @@ public final class GuassLegendre {
|
||||
* l: No of loops to run
|
||||
*/
|
||||
|
||||
double a = 1, b = Math.pow(2, -0.5), t = 0.25, p = 1;
|
||||
double a = 1;
|
||||
double b = Math.pow(2, -0.5);
|
||||
double t = 0.25;
|
||||
double p = 1;
|
||||
for (int i = 0; i < l; ++i) {
|
||||
double[] temp = update(a, b, t, p);
|
||||
a = temp[0];
|
||||
|
@ -178,7 +178,8 @@ public final class KochSnowflake {
|
||||
*/
|
||||
private static class Vector2 {
|
||||
|
||||
double x, y;
|
||||
double x;
|
||||
double y;
|
||||
|
||||
Vector2(double x, double y) {
|
||||
this.x = x;
|
||||
|
@ -7,7 +7,8 @@ final class Krishnamurthy {
|
||||
}
|
||||
|
||||
static int fact(int n) {
|
||||
int i, p = 1;
|
||||
int i;
|
||||
int p = 1;
|
||||
for (i = n; i >= 1; i--) {
|
||||
p = p * i;
|
||||
}
|
||||
@ -16,7 +17,9 @@ final class Krishnamurthy {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
int a, b, s = 0;
|
||||
int a;
|
||||
int b;
|
||||
int s = 0;
|
||||
System.out.print("Enter the number : ");
|
||||
a = sc.nextInt();
|
||||
int n = a;
|
||||
|
@ -9,7 +9,10 @@ package com.thealgorithms.others;
|
||||
*/
|
||||
public class LinearCongruentialGenerator {
|
||||
|
||||
private double a, c, m, previousValue;
|
||||
private final double a;
|
||||
private final double c;
|
||||
private final double m;
|
||||
private double previousValue;
|
||||
|
||||
/**
|
||||
* *
|
||||
|
@ -55,7 +55,9 @@ public class MiniMaxAlgorithm {
|
||||
* @return The optimal score for the player that made the first move.
|
||||
*/
|
||||
public int miniMax(int depth, boolean isMaximizer, int index, boolean verbose) {
|
||||
int bestScore, score1, score2;
|
||||
int bestScore;
|
||||
int score1;
|
||||
int score2;
|
||||
|
||||
if (depth == height) { // Leaf node reached.
|
||||
return scores[index];
|
||||
|
@ -5,7 +5,9 @@ import java.util.Scanner;
|
||||
class PageRank {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int nodes, i, j;
|
||||
int nodes;
|
||||
int i;
|
||||
int j;
|
||||
Scanner in = new Scanner(System.in);
|
||||
System.out.print("Enter the Number of WebPages: ");
|
||||
nodes = in.nextInt();
|
||||
|
@ -58,7 +58,8 @@ final class Rotate {
|
||||
}
|
||||
}
|
||||
}
|
||||
int i = 0, k = n - 1;
|
||||
int i = 0;
|
||||
int k = n - 1;
|
||||
while (i < k) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
int temp = a[i][j];
|
||||
|
@ -59,7 +59,8 @@ public class SkylineProblem {
|
||||
}
|
||||
|
||||
public ArrayList<Skyline> mergeSkyline(ArrayList<Skyline> sky1, ArrayList<Skyline> sky2) {
|
||||
int currentH1 = 0, currentH2 = 0;
|
||||
int currentH1 = 0;
|
||||
int currentH2 = 0;
|
||||
ArrayList<Skyline> skyline = new ArrayList<>();
|
||||
int maxH = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user