mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-07 09:45:04 +08:00
Removed the Misc directory and moved the files to other
This commit is contained in:
@ -1,17 +0,0 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
for(int i=0; i < r; i++) {
|
||||
for(int j=0; j <= i; j++) {
|
||||
System.out.print(++n + " ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.text.*;
|
||||
import java.math.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Solution {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//take input
|
||||
Scanner scn = new Scanner(System.in);
|
||||
|
||||
int N = scn.nextInt(); //N is the input number
|
||||
int P = scn.nextInt(); //P is precision value for eg - P is 3 in 2.564 and 5 in 3.80870.
|
||||
|
||||
System.out.println(squareRoot(N, P));
|
||||
}
|
||||
|
||||
public static double squareRoot(int N, int P) {
|
||||
double rv = 0; //rv means return value
|
||||
|
||||
double root = Math.pow(N, 0.5);
|
||||
|
||||
//calculate precision to power of 10 and then multiply it with root value.
|
||||
int precision = (int) Math.pow(10, P);
|
||||
root = root * precision;
|
||||
/*typecast it into integer then divide by precision and again typecast into double
|
||||
so as to have decimal points upto P precision */
|
||||
|
||||
rv = (int)root;
|
||||
return (double)rv/precision;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class FloydTriangle {
|
||||
|
||||
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: ");
|
||||
|
@ -1,4 +1,8 @@
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.text.*;
|
||||
import java.math.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Solution {
|
||||
|
||||
|
Reference in New Issue
Block a user