Tag: ATI BSP oid reader void i+1 input HTTP number
Enter a one-dimensional array, with the largest interchange with the first element, the smallest with the last element, and the output array.
public class Shuzujiaohuan {
public static void Main (string[] args) {
//TODO Auto-generated method stub
scanner reader=new Scanner ( system.in);
int[] A=new int[10];
for (int i=0;i<a.length;i++) {
system.out.print ("Please enter" +a.length+ "number, current" + (i+1) + "A:");
a[i]=reader.nextint ();
}
int max=0,min=0,c=0;
max=a[0];
min=a[0];
for (int i=0;i<a.length;i++)
{
if (a[i]>=max)
Max=a[i];
if (a[i]<=min)
min=a[i];
}
int m=0,n=0;
for (int i=0;i<a.length;i++) {
if (max==a[i])
n=i;
if (Min==a[i])
m=i;
}
C=A[0];
A[0]=max;
A[n]=c;
C=A[A.LENGTH-1];
A[a.length-1]=min;
A[m]=c;
for (int i=0;i<a.length;i++)
System.out.println (A[i]);
}
}
Enter a one-dimensional array, with the largest interchange with the first element, the smallest with the last element, and the output array.