作业

 1 第一题
 2         
 3         long arr1[] = new long[]{1,2,3,4,5};
 4         
 5         long arr2[] = Arrays.copyOfRange(arr1, 0, 3);
 6         
 7         int i =0;
 8         while(i < arr1.length)
 9         {
10             System.out.print(" "+arr1[i]);
11             i++;
12         }
13         System.out.println();
14         int j = 0;
15         while(j < arr2.length)
16         {
17             System.out.print(" "+arr2[j]);
18             j++;
19         }
20         System.out.println();
21         
22     //第二题
23         
24         long xsz[] = new long[]{2,56,98,43,1,3}; 
25         
26         for(long a = xsz.length;a > 0;a--)
27         {
28             for(int b = 0;b < xsz.length - 1;b++)
29             {
30                 if(xsz[b] > xsz[b + 1])
31                 {
32                     long c = xsz[b];
33                     
34                     xsz[b] = xsz[b + 1];
35                     
36                     xsz[b + 1] = c;
37                 }
38             }
39         }
40         for(long v : xsz)
41         {
42             System.out.print(v +",");
43         }
44         System.out.println();
45         System.out.println(" " + xsz[0]);
46         
习题1、2两个题
原文地址:https://www.cnblogs.com/name-hanlin/p/4865369.html