Java数组排序总结(冒泡,选择,插入,希尔)

PLC凸轮开关指令编程应用——控制算法 凸轮开关指令的作用是在PLC程序中根据凸轮开关(Cam Switch)的状态执行不同的操作。凸轮开关通常是机械式的开关装置,它的位置会随着机械运动的变化而改变。凸轮开关的状态可以用来检测机器的位置、角度或其他相关信息,从而触发相应的控制动作。总结起来,凸轮开关指令是PLC编程中常用的一种控制算法,通过检测凸轮开关的状态来触发相应的操作。本文将介绍凸轮开关指令的应用和相应的控制算法,并提供相关的源代码示例。在这个示例中,凸轮开关状态的值代表不同的位置,根据凸轮开关状态的不同,执行相应的动作。 阅读详情
public class SortAll {

	/**
	 * 冒泡排序,选择排序,插入排序,希尔(Shell)排序 Java的实现 2008.11.09
	 * 
	 * @author YangL. (http://www.idcn.org)
	 */
	public static void main(String[] args) {
		int[] i = { 1, 5, 6, 12, 4, 9, 3, 23, 39, 403, 596, 87 };
		System.out.println("----冒泡排序的结果:");
		maoPao(i);
		System.out.println();
		System.out.println("----选择排序的结果:");
		xuanZe(i);
		System.out.println();
		System.out.println("----插入排序的结果:");
		chaRu(i);
		System.out.println();
		System.out.println("----希尔(Shell)排序的结果:");
		shell(i);
	}

	// 冒泡排序
	public static void maoPao(int[] x) {
		for (int i = 0; i < x.length; i++) {
			for (int j = i + 1; j < x.length; j++) {
				if (x[i] > x[j]) {
					int temp = x[i];
					x[i] = x[j];
					x[j] = temp;
				}
			}
		}
		for (int i : x) {
			System.out.print(i + " ");
		}
	}

	// 选择排序
	public static void xuanZe(int[] x) {
		for (int i = 0; i < x.length; i++) {
			int lowerIndex = i;
			// 找出最小的一个索引
			for (int j = i + 1; j < x.length; j++) {
				if (x[j] < x[lowerIndex]) {
					lowerIndex = j;
				}
			}
			// 交换
			int temp = x[i];
			x[i] = x[lowerIndex];
			x[lowerIndex] = temp;
		}
		for (int i : x) {
			System.out.print(i + " ");
		}
	}

	// 插入排序
	public static void chaRu(int[] x) {
		for (int i = 1; i < x.length; i++) {// i从一开始,因为第一个数已经是排好序的啦
			for (int j = i; j > 0; j--) {
				if (x[j] < x[j - 1]) {
					int temp = x[j];
					x[j] = x[j - 1];
					x[j - 1] = temp;
				}
			}
		}
		for (int i : x) {
			System.out.print(i + " ");
		}
	}

	// 希尔排序
	public static void shell(int[] x) {
		// 分组
		for (int increment = x.length / 2; increment > 0; increment /= 2) {
			// 每个组内排序
			for (int i = increment; i < x.length; i++) {
				int temp = x[i];
				int j = 0;
				for (j = i; j >= increment; j -= increment) {
					if (temp < x[j - increment]) {
						x[j] = x[j - increment];
					} else {
						break;
					}
				}
				x[j] = temp;
			}
		}

		for (int i : x) {
			System.out.print(i + " ");
		}
	}
}

 
【DaVinci Developer专题】-23-IDT高阶应用:结构体类型的数组 共8页 目录 1 创建一个Record IDT 2 创建一个Array IDT 3 创建一个S/R Port Interface 4 创建一个Constant 5 导入CFG生成代码的总结 6 结尾 <--返回「实战篇」博文-总目录--> <--返回「Autosar从入门到精通-实战篇」专栏主页--> 关键字: 缩略语/术语 含义 DEV DaVinci Developer . 阅读详情

相关推荐

顶级的FDE需要拥有哪些技能?

上一篇《》说明白了什么是FDE。这一篇回答下一个问题:要成为顶级 FDE,需要哪些具体的技能?要想弄清楚FDE应该有哪些能力,就得先搞清楚FDE要完成哪些工作。同时,有一点是我们要密切关注的:现在是大模型时代,所以我们不能脱离大模型讨论FDE的能力。我们可以把FDE在客户现场需要完成的工作分为四类:破冰与诊断、价值交付、项目与预期管理、沟通与影响。另有两项元能力贯穿始终。以下按工作类别逐一拆解,每项能力配 1 / 3 / 5 分标准,方便对照自评。文末有完整打分工具链接。

mydeman的学习日志 258

Java数据结构排序总结

如果不用递归,我们就需要模拟递归的这个过程,需要用合适的数据结构,在递归的过程中,主要是需要重新找新的left和right下标,所以先去照一次基准,此时就有了递归时的L下标和R下标,可以用栈来存放每次递归时需要的L和R下标,出栈时,出一个数据给到R下标,出栈一个值给到L下标,进行两边找基准,当栈不为空的时候,就出栈两个下标,根据这两个下标来继续找新的基准,此时出栈元素之后要根据这两个下标判断左右是否只有一个元素,当只有一个数据的时候,就不能入栈了。当栈弹空了,也就排序完成了。这也减少了递归的次数。

weixin_64874291的博客 570

数据中心光模块升级实录:从200G QSFP56到400G QSFP-DD的踩坑指南

本文记录了数据中心从200G QSFP56升级至400G QSFP-DD光模块的完整实战经验。文章深入剖析了升级过程中面临的兼容性、链路预算、布线、散热与功耗管理等核心挑战,并提供了具体的解决方案与排坑指南,为高速网络升级提供了宝贵的实践参考。

butter的博客 479

【Java】数组操作 之 数组排序

对数组进行排序是程序中非常基本的需求。常用的排序算法有冒泡排序、插入排序和快速排序等。

ihero的博客 2971

STM32驱动四位共阳极数码管实现高精度秒表计时器

本文详细介绍了如何使用STM32驱动四位共阳极数码管实现高精度秒表计时器。项目基于STM32F103C8T6最小系统板,通过定时器中断和GPIO控制,实现0.1秒精度的计时功能,并解析了共阳极数码管的动态扫描原理及按键消抖等关键技术。

n8m7b6v5c4的博客 951

一文帮你彻底搞懂ARM Debug Interface之SWD(转)

ARM的文档写的已经很好了,但是关于上电以后的第一时间应该怎么操作,依然写的不够清晰,导致我第一次用的时候还是费了一些周折。今天做一个详细的梳理,希望能够帮助到更多的朋友。BTW, ARM_Cortex-M0/3 DesignStart系列会持续更新,只是中间可能会穿插其他知识点。SWD是Serial Wire Debug的简称,翻译成中文是”串行线调试”。

2302_79847220的博客 6861

Java算法排序实验的实验心得_20162311 实验三-查找与排序 实验报告

20162311 实验三-查找与排序 实验报告目录一、查找与排序-1(一) 实验目的(二) 实验过程Searching.java和Sorting.java是书上已经写好的类,只需进行junit测试就行。为了体现查找的异常情况,我在线性查找中添加了一个在数组中不存在的测试用例,二分查找则通过逆序(即降序)来体现异常情况测试截图线性查找正常线性查找异常二分查找正序二分查找逆序选择排序插入排序冒泡排序快...

weixin_30616309的博客 5382

SAP中错记虚拟利润中心的调整,冲销处理实例

我非CO专业顾问。工作中遇到的问题,也会找资料,分析,测试。有时这个过程会拿到结果,解决问题。遂将过程记录下来备查。读者请谨慎参考!EC-PCA: 利润中心记账流程_9ke0-优快云博客。

专注SAP应用技术文章写作,致力于拉近用户与系统间的距离; 1795

java数组实验心得体会_JAVA实验报告 数组

实验一1、实验题目编写一个Java应用程序,该程序在命令行窗口输出希腊字母表。2、程序代码publicclassGreekAlphabet{publicstaticvoidmain(Stringargs[]){intstartPosition=0,endPosition=0;charcStart='α',cEnd='ω';startPosition=(int)cStart;endPo...

weixin_39637646的博客 1104

solidworks vba二次开发配合问题

solidworks vba二次开发配合问题二次开发装配的步骤 二次开发装配的步骤 solidworks可以使用宏录制配合过程从而得到配合的vba代码,步骤如下: 1.选择两个配合的面(点、线等) 2. 建立配合 例如将两个圆柱面同心(图中高亮): 配合后 我们看一下宏录制的代码: Sub main() //激活solidworks接口 Set swApp = Application.SldWorks Set Part = swApp.ActiveDoc //选择两个圆柱面,注意此处是根据坐标选择,不

Alejandro123的博客 3404

手把手教你用GPIO模拟MDIO时序,搞定Linux下那些‘不听话’的PHY芯片

本文详细介绍了如何利用Linux内核的`virtual,mdio-gpio`驱动,通过GPIO模拟MDIO时序来解决特殊PHY芯片的驱动调试问题。从硬件准备、设备树配置到驱动实现,提供了完整的解决方案和实战案例,帮助开发者应对非标准时序的PHY芯片挑战。

weixin_29188043的博客 269

java基础八(数组排序总结)

数组常用排序方法:import java.util.Arrays; /* * Java 自带数组排序Arrays.sort(nums); * Java自带时钟函数 * startTime = System.currentTimeMillis();//记录毫秒 */ public class Test { public static void main(String[] args) {...

wtdm_160604的博客 328

[实践篇]13.13 再来梳理一下HAB的设计原理

HAB全称为Hypervisor Abstraction,即硬件抽象,主要用于提供对HOST OS硬件资源的访问。

从0到1,突破自己 7258

java类实现数组的五种排序 冒泡排序、选择排序、插入排序、希尔排序、数组排序

public class sort { /** * @param args * 对数组进行排序冒泡排序、选择排序、插入排序、希尔排序、数组排序 * 五种排序的方法 */ public static void main(String[] args) { // TODO Auto-generated method stub int a[] = new int[7]; a[0]=12; a

何足道也 815

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

java数组排序算法01-冒泡,选择,希尔排序,插入排序

java数组排序算法 冒泡排序 原理:数组元素两两比较,交换位置,大元素往后放,经过一轮比较后,最大的元素,就会出现在最大索引处。 O(n^2) public class BubbleSort { public static void main(String[] args) { int[] arr = {1,34,23,3,45,6}; int[] arr2 = bubble(arr); for (int i = 0; i < arr2.leng

shake_shark_pp 162

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Java数组排序总结(冒泡,选择,插入,希尔)

package org.idcn.jse;    public class SortAll {     /**   * 冒泡排序,选择排序,插入排序,希尔(Shell)排序 Java的实现    * 2008.11.09   * @author YangL. (http://www.idcn.org)   */   public static void main(String[] args) {

liujinwei2005的专栏 702

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Java数组排序(冒泡,选择,插入,希尔)

[code="java"] public class SortAll { /** * 冒泡排序,选择排序,插入排序,希尔(Shell)排序 Java的实现 * 2008.11.09 * @author YangL. (http://www.idcn.org) */ public static void main(String...

JavaNoob的博客 144

java 数组 起泡排序_Java数组排序(冒泡,选择,插入,希尔)

public class SortAll {/*** 冒泡排序,选择排序,插入排序,希尔(Shell)排序 Java的实现* 2008.11.09* @author YangL. (http://www.idcn.org)*/public static void main(String[] args) {int[] i = { 1, 5, 6, 12, 4, 9, 3, 23, 39, 403, ...

weixin_33511258的博客 78

Java数组排序总结(冒泡,选择,插入,希尔)

public class SortAll {      /**    * 冒泡排序,选择排序,插入排序,希尔(Shell)排序 Java的实现     * 2008.11.09    * @author YangL. (http://www.idcn.org)    */   public static void main(String[] args) {     int[] i = { 1, 5

ihc523的专栏 540

Java实现数组排序总结篇(冒泡,选择,插入,希尔)

package org.liuxin.interview; /** * * @author LiuBeY(http://liubey.iteye.com) */ public class SortAll { public static void main(String[] args) { int[] i = { 1, 5, 6, 12, 4, 9...

Liubey的只言片语 137

数组排序(选择、快速、希尔、冒泡、直接插入排序)--java语言编写

1.直接插入排序 //直接插入排序 int[]arr={49,38,65,97,76,13,27}; //外层定义比较的轮次 for (int i = 0; i < arr.length-1; i++) { //内层定义比较的东西 for (int j = i+1; j >0 ; j--) ...

qq_42022411的博客 296
上一篇: Struts2的Annotation使用
下一篇: sql语句 int 后面跟数组
Mr.Z003
博客等级 码龄16年 82粉丝 41原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值