**
1. Count the number of conversions .
2. Transposition algorithm :for Cycle to achieve
<1>. Assign the value on the left to the temporary variable
<2>. Assign the value on the right to the left
<3>. Assign the value of the temporary variable to the right
3. Traversal array , See if it's swapping .
**
package lession11;
public class Demo01 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] array= {2,8,6,33,45,97,22,108,100};
// Calculate the number of exchanges
int count=array.length/2;
//System.out.println(count);
// Traversal of the original array
/*
for(int i=0;i<array.length;i++){
System.out.println(" Original array :"+array[i]);
}
*/
for(int i=0;i<count;i++) {
int left=i;
int right=array.length-i-1;
// Assign the value on the left to the temporary variable
int tep=array[left];
// Assign the value on the right to the left
array[left]=array[right];
// Assign the value of the temporary variable to the right
array[right]=tep;
}
// Traversal array
for(int i=0;i<array.length;i++) {
System.out.println(" Swapped array :"+array[i]);
}
}
}
Please criticize and correct me , thank you .