zoukankan      html  css  js  c++  java
  • 一维数组 冒泡排序

    1、数组:具有相同类型的若干变量按有序的形式组织起来的一种形式。这些按序排列的同类数据元素的集合称为数组。int[] 变量名 = new int [n];

    如int [] array = new int [5]{1,2,3,4,5};表示int一个叫做array的5个数整型数字,其中5个数字是1,2,3,4,5。般情况下,没有花括号!

    2、冒泡排序

    格式:

    1 int temp;
    2             int[] arrSort = new int[7] { 10, 8, 3, 5, 6, 7, 9 };
    3             for (int i = 0; i < arrSort.Length; i++)
    4             {
    5                 for (int j = i + 1; j < arrSort.Length; j++)
    6                 {
    7                     if (arrSort[j] < arrSort[i])
    8                     {
    9                         temp = arrSort[j];
    10                         arrSort[j] = arrSort[i];
    11                         arrSort[i] = temp;
    12                     }
    13                 }
    14             }

    完!!

  • 相关阅读:
    字符串的问题(strstr和strncpy 水题)
    数一数(KMP+思维)
    栗酱的数列(KMP+思维)
    D. Almost All Divisors(思维)
    E. Two Arrays and Sum of Functions(贪心)
    好位置(思维)
    Just A String(kmp)
    Dubbo简介
    lambda表达式快速创建
    分布式RPC系统框架Dubbo
  • 原文地址:https://www.cnblogs.com/wwz-wwz/p/5713115.html
Copyright © 2011-2022 走看看