1.package finish;
import java.util.Scanner;
public class csy {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("请输入数组的值");
int [] a = new int [5] ;
for (int i = 0; i < a.length; i++) {
a[i]=input.nextInt();
}
for(int i=0;i<a.length-1;i++){
for(int j=0;j<a.length-1-i;j++){
if(a[j]>a[j+1]){
int temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
System.out.println("冒泡排序后输出为");
for(int i=0;i<a.length;i++)
{
System.out.print(a[i]+" ");
}
}
}
![](https://img2020.cnblogs.com/blog/1967842/202004/1967842-20200415110738255-1746510385.png)
2.package finish;
import java.util.Scanner;
public class csy {
public static void main(String[] args) {
int [] a = new int [] {34,22,35,67,45,66,12,33} ;
Scanner input=new Scanner(System.in);
System.out.println("输入想查询的数字");
int i=input.nextInt();
int b=0;
for(int j=0;j<a.length;j++){
if(a[j]==i){
System.out.println("该数存在于数组中下标为"+j);
b=1;
}
}
if(b==0)
{
System.out.println("not found");
}
}
}
![](https://img2020.cnblogs.com/blog/1967842/202004/1967842-20200415110758011-494137150.png)
3.package finish;
import java.util.Scanner;
public class csy {
public static void main(String[] args) {
double[][]arr={{1,1,1,1},{2,2,2,2},{3,3,3,3},{4,4,4,4},{5,5,5,5}};
for(int i=0;i<arr.length;i++){
System.out.println();
for(int j=0;j<arr[i].length;j++){
System.out.print(arr[i][j]+" ");
}
}
}
}
![](https://img2020.cnblogs.com/blog/1967842/202004/1967842-20200415110818437-1504002013.png)
4.package finish;
import java.util.Scanner;
public class csy {
public static void main(String[] args) {
int arr[][]={{1,3,5},{2,4,6},
{5,2,1},{13,14,9}};
int max=arr[0][0];
for(int i=0;i<arr.length;i++){
for(int j=0;j<arr[i].length;j++){
if(arr[i][j]>max){
max=arr[i][j];
}
}
}
System.out.println("该二维数组的最大值为"+max);
}
}
![](https://img2020.cnblogs.com/blog/1967842/202004/1967842-20200415110841399-1774156132.png)