本人是java新人,对目前的数组冒泡排序有点迷糊
- package imooc;
- public class ceshi
- {
- public static void main(String[] args)
- {
- //定义数组,保存成绩
- int[] scores = {89,-23,64,91,119,52,73};
- //调用方法
- shuzu(scores);
- print(scores);
- }
- public static void shuzu(int[] scores) //成绩排序
- {
- for(int i=0;i<scores.length-1;i++)
- {
- for(int j=0;j<scores.length-i-1;j++)
- {
- if(scores[j]>scores[j+1])
- {
- int x=scores[j];
- scores[j]=scores[j+1];
- scores[j+1]=x;
- }
- }
- }
- }
- public static void print(int[] scores) //循环遍历输出数组
- {
- for(int xs=0;xs<scores.length;xs++)
- {
- System.out.println(scores);
- }
- }
- }
复制代码 哪里出问题了? |
|