输出未能排序

    import java.util.Scanner;
    import java.util.Arrays;
    public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n =sc.nextInt();
     sc.nextLine();
            String[] ID =new String[n];
            for (int i=0;i<n;i++) {
                ID[i]=sc.nextLine();
            }
            for (int i=0;i<n;i++) {
                for (int j=i;j<n-1;j++) {
                    if (Integer.parseInt(ID[j].substring(6,10))>Integer.parseInt(ID[j+1].substring(6,10))) {
                        String Tmp = ID[j];
                        ID[j] =ID[j+1];
                        ID[j+1]= Tmp;
                        
                    }else if(Integer.parseInt(ID[j].substring(6,10))==Integer.parseInt(ID[j+1].substring(6,10))){
                        if(Integer.parseInt(ID[j].substring(10,12))>Integer.parseInt(ID[j+1].substring(10,12))){
                            String Tmp = ID[j];
                            ID[j]=ID[j+1];
                            ID[j+1]=Tmp;
                        }
                        else if (Integer.parseInt(ID[j].substring(10,12))==Integer.parseInt(ID[j+1].substring(10,12))){
                             if (Integer.parseInt(ID[j].substring(12,14))>Integer.parseInt(ID[j+1].substring(12,14))) {
                                 String Tmp =ID[j];
                                 ID[j]=ID[j+1];
                                 ID[j+1]=Tmp;
                             }
                        }
                    }
                }
            }
            for(;;) {
                String tmp=sc.nextLine();
                if (tmp.equals("sort1"))
                {
                    for(int i=0;i<n;i++) {
                        System.out.println(ID[i].substring(6,10)+"-"+ID[i].substring(10,12)+"-"+ID[i].substring(12,14));
                    }
                    }else if (tmp.equals("sort2")) {
                    for (int i=n-1;i>=0;i--) {
                        System.out.println(ID[i]);
                    }
                }else{
                    
                    System.out.println("exit");
                    break;
                }
            }
        }
                    
        }   

最新文章

  1. 自用有线IP切换
  2. windows日常软件推荐
  3. 未能加载文件或程序集“Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。
  4. 玩转iOS开发 - 简易的实现2种抽屉效果
  5. 赋值,copy和deepcopy
  6. Css中的变形及过渡动画
  7. Vue2.0环境搭建和测试demo
  8. [key]严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener(Spring配置异常)
  9. ubuntu-14.10下,安装gcc交叉编译器遇到问题及解决方法
  10. 初识Windous程序
  11. Xilinx ISE 14.1利用Verilog产生clock
  12. oracle session数激增排查过程
  13. java基础----&gt;java8中的函数式接口
  14. laravel----------如何优化laravel框架
  15. JSPatch实现原理详解&lt;二&gt;
  16. SpringBoot入门篇--读取资源文件配置
  17. bzoj 4689: Find the Outlier
  18. TestNG+Maven+IDEA 自动化测试(一) 环境搭建
  19. sort命令与cat区别
  20. django中的setting最佳配置小结

热门文章

  1. InputNumber计数器
  2. 【python3】configparser读取ini配置文件
  3. react目录结构、demo实例详解、属性数据绑定方式
  4. fiddler配置会话框菜单栏
  5. harbor仓库安装
  6. java:(监听,上传,下载)
  7. Unity2D RPG游戏开发日志
  8. 【VS开发】【图像处理】 bayer, yuv, RGB转换方法
  9. xshell登陆后脚本
  10. 几个关于json序列化 的注解