Example: Finding the number of sequences and
Input two integer n,m, the middle is separated by a space, N is the first item, the following items are the previous open root, and the first M.
The first way to enter and read from the keyboard: the Sc.hasnextint () function and the Sc.nextint () function
Hasnextint () determines whether the current input is an integer
Import Java.util.Scanner;
Import java.lang.math.*;
Class test1{public
static void Main (String [] args) {
Scanner sc=new Scanner (system.in);
int m;
Double N,result;
while (Sc.hasnextint ()) {
n=sc.nextint ();
M=sc.nextint ();
result=0;
for (int i=0; i<m; i++) {result
= N;
n = math.sqrt (n);
}
System.out.printf ("%.2f", result);
}
}
The second way: the Sc.trim () function and the Sc.split () function
Sc.trim () Remove string and tail space
Sc.split () splits a string according to the specified character (string) or regular, and the result is returned as an array of strings
Import Java.util.Scanner;
Import java.lang.math.*;
Class test{public
static void main () {
Scanner sc=new Scanner (system.in);
String input=sc.nextline ();
Input=input.trim ()//Remove string
string[] Temp=input.spilt (""); Splits a string according to the specified string and returns a
double n=integer.parsedouble (temp[0] as an array of strings);
int M=integer.parseint (temp[1]);
Double result=0;
for (int i=0; i<m; i++) {result
= N;
n = math.sqrt (n);
}
SYSTEM.OUT.PRINTLN (result);
}