• 快速插入排序、冒泡排序


    快速插入排序
    public InsertSort() {
                 int[] a = { 12, 32, 34, 2, 3, 4, 54, 234, 6, 65, 34, 2, 3, 534, 6 };
                 int temp = 0;
                 for (int i = 1; i < a.length; i++) {
                       int j = i - 1;
                      temp = a[i];
                       for (; j >= 0 && temp < a[j]; j--) {
                            a[j + 1] = a[j];
                      }
                      a[j + 1] = temp;
                }
                 for (int i = 1; i < a.length; i++) {
                      System. out.println(a[i]);
                }
          }
    
           public static void main(String[] s) {
                 new InsertSort();
          }
    
    冒泡排序:
    public void mopao() {
                 int[] a = { 12, 32, 34, 2, 3, 4, 54, 234, 6, 65, 34, 2, 3, 534, 6 };
                 for (int i = 0; i < a.length; i++) {
                       for (int k = 0; k < a.length; k++) {
                             if (a[i] < a[k]) {
                                   int temp = 0;
                                  temp = a[i];
                                  a[i] = a[k];
                                  a[k] = temp;
                            }
                      }
                }
                 for (int i = 1; i < a.length; i++) {
                      System. out.println(a[i]);
                }
          }
    

      

  • 相关阅读:
    Restful风格
    SpringMVC概念、原理及搭建
    Mybatis搭建
    HttpServletRequest、HttpServletResponse、Cookie、Session
    Servlet基础
    Spring整合Mybatis
    PHP代码标识
    IOC及Bean容器
    框架
    Spring概况
  • 原文地址:https://www.cnblogs.com/tatame/p/2642931.html
Copyright © 2020-2023  润新知