Define an array of length of 10 plastic, the values in the array is initially defined, 10,12,14,9,7,5,22,0,11,6 respectively, and the program will do a tail in the array elements displacement, namely, the first element array and array exchange, the last element, the second element and the penultimate element exchange, according to the final output,
CodePudding user response:
To easy to understand, at the end of a coordinate point to a pointer to the front, and then after exchange at the end of the 1, + 1, in front of the most until coordinates coincide stops
CodePudding user response:
reference 1st floor PHOloe response: to a straightforward, a coordinate points to a point at the end of the front, and then after exchange at the end of the 1, + 1, in front of the most until coordinates coincide stop I will not knock wow?? CodePudding user response:
reference 1st floor PHOloe response: to a straightforward, a coordinate points to a point at the end of the front, and then after exchange at the end of the 1, + 1, in front of the most until coordinates coincide stop Yao screenshots china-arab also can play code CodePudding user response:
refer to the second floor weixin_46480824 response: Quote: refer to 1st floor PHOloe response: to easy to understand, at the end of a coordinate points to a point to the front, and then after exchange at the end of the 1, + 1, in front of the most until coordinates coincide stop I will not knock? Public class HelloWorld { Public static void main (String [] args) { Int [] ary=new int [],12,14,9,7,5,22,0,11,6 {10}; Int I=0, j=9; int t; While (i T=ary [I]; Ary [I]=ary [j]; Ary [j]=t; i++; j--; } for(int index=0; Index<10; Index++) { System. The out. Println (ary [index]); } } } CodePudding user response:
Public static void main (String [] args) { 10,12,14,9,7,5,22,0,11,6 int [] array={}; //median, used to do in the exchange of Int ZJS; //just traversal see for (int i=0; i System. The out. Print (array [I] + "\ t"); } //because exchange only half traversal for (int i=0; i //median, used to do in the exchange of ZJS=array [I]; //starting from 0, so minus 1 Array [I]=array (array. The length - I - 1); Array [array. The length - I - 1]=ZJS; } System.out.println(); for (int i=0; i System. The out. Print (array [I] + "\ t"); } } CodePudding user response:
Head position is in reverse order output, so try this: Public class HelloWorld { Public static void main (String [] args) { Int [] 'arry=new int [],12,14,9,7,5,22,0,11,6 {10}; For (int I=9. I>=0; I -) { System. The out. Println (' arry [I]); CodePudding user response:
Answer next time you see knots rate CodePudding user response:
To teach fishing is better than teach them to fish, it is important to learn thinking, rather than to Besides this person's knot rate of 0, you give the answer is a waste of time, CodePudding user response:
Int [] numArr={10, 12, 14, 9, 7, 5, 22, 0, 11, 6}; ArrayList NumArrList=(ArrayList) Arrays. Stream (numArr) boxed () collect (Collectors. ToList ()); The Collections. Reverse (numArrList); NumArr=numArrList. Stream (). MapToInt (x & gt; X). ToArray (); Regardless of the code efficiency, the theory of single speed of programming I this code is the optimal solution, does not accept any counter, knot knot not doesn't matter, stroll BBS is to pass the time