Home > Back-end >  To solve the
To solve the

Time:09-25

CodePudding user response:

 
Public static void main (String [] args) {
Int lastInput=0;
List List=new ArrayList<> (a);
Scanner sc=new Scanner(System.in);
System. The out. Println (" please enter a number 10 0-99: ");
for (int i=0; i <10; I++) {
Int num=sc. NextInt ();
If (num> 99 | | num<0 {
System. Out.println (" beyond the scope of the Numbers!!! Your input is: "+ num);
return;
}
//when the input for the first time, do not need to be added to the list
If (I.=0) {
List. Add (lastInput * num);
}
//record the number of the input
LastInput=num;
}
//take the three biggest number
List Collect=list. Stream (.) sorted ((i1, i2) - & gt; I2 - i1). Limit (3) collect (Collectors. ToList ());
Collect. Stream (). ForEach (I - & gt; System. The out. Println (I));
}

CodePudding user response:

reference 1st floor qq_41622282 response:
 
Public static void main (String [] args) {
Int lastInput=0;
List List=new ArrayList<> (a);
Scanner sc=new Scanner(System.in);
System. The out. Println (" please enter a number 10 0-99: ");
for (int i=0; i <10; I++) {
Int num=sc. NextInt ();
If (num> 99 | | num<0 {
System. Out.println (" beyond the scope of the Numbers!!! Your input is: "+ num);
return;
}
//when the input for the first time, do not need to be added to the list
If (I.=0) {
List. Add (lastInput * num);
}
//record the number of the input
LastInput=num;
}
//take the three biggest number
List Collect=list. Stream (.) sorted ((i1, i2) - & gt; I2 - i1). Limit (3) collect (Collectors. ToList ());
Collect. Stream (). ForEach (I - & gt; System. The out. Println (I));
}

Hello with array can

CodePudding user response:

reference chicken dishes code on the second floor of the road of reply:
Quote: refer to 1st floor qq_41622282 response:
 
Public static void main (String [] args) {
Int lastInput=0;
List List=new ArrayList<> (a);
Scanner sc=new Scanner(System.in);
System. The out. Println (" please enter a number 10 0-99: ");
for (int i=0; i <10; I++) {
Int num=sc. NextInt ();
If (num> 99 | | num<0 {
System. Out.println (" beyond the scope of the Numbers!!! Your input is: "+ num);
return;
}
//when the input for the first time, do not need to be added to the list
If (I.=0) {
List. Add (lastInput * num);
}
//record the number of the input
LastInput=num;
}
//take the three biggest number
List Collect=list. Stream (.) sorted ((i1, i2) - & gt; I2 - i1). Limit (3) collect (Collectors. ToList ());
Collect. Stream (). ForEach (I - & gt; System. The out. Println (I));
}

Hello with array can you
can ah

CodePudding user response:

reference chicken dishes code on the second floor of the road of reply:
Quote: refer to 1st floor qq_41622282 response:
 
Public static void main (String [] args) {
Int lastInput=0;
List List=new ArrayList<> (a);
Scanner sc=new Scanner(System.in);
System. The out. Println (" please enter a number 10 0-99: ");
for (int i=0; i <10; I++) {
Int num=sc. NextInt ();
If (num> 99 | | num<0 {
System. Out.println (" beyond the scope of the Numbers!!! Your input is: "+ num);
return;
}
//when the input for the first time, do not need to be added to the list
If (I.=0) {
List. Add (lastInput * num);
}
//record the number of the input
LastInput=num;
}
//take the three biggest number
List Collect=list. Stream (.) sorted ((i1, i2) - & gt; I2 - i1). Limit (3) collect (Collectors. ToList ());
Collect. Stream (). ForEach (I - & gt; System. The out. Println (I));
}

Hello with array can you

I'll write to you tomorrow, the list can also be converted to an array,

CodePudding user response:

 
Public static void main (String [] args) {
Int lastInput=0;
//to prepare a deposit results array
Int [] arr=new int [9].
Scanner sc=new Scanner(System.in);
System. The out. Println (" please enter a number 10 0-99: ");
for (int i=0; i <10; I++) {
Int num=sc. NextInt ();
If (num> 99 | | num<0 {
System. Out.println (" beyond the scope of the Numbers!!! Your input is: "+ num);
return;
}
//when the input for the first time, do not need to be added to the list
If (I.=0) {
Arr=[I - 1] lastInput * num;
}
//record the number of the input
LastInput=num;
}
//take the three biggest number
Arrays.sort(arr);
For (int I=1; i <=3; I++) {
System. The out. Println (arr [arr. Length - I]);
}
}

CodePudding user response:

reference chicken dishes code on the second floor of the road of reply:
Quote: refer to 1st floor qq_41622282 response:
 
Public static void main (String [] args) {
Int lastInput=0;
List List=new ArrayList<> (a);
Scanner sc=new Scanner(System.in);
System. The out. Println (" please enter a number 10 0-99: ");
for (int i=0; i <10; I++) {
Int num=sc. NextInt ();
If (num> 99 | | num<0 {
System. Out.println (" beyond the scope of the Numbers!!! Your input is: "+ num);
return;
}
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related