NumSort

本文介绍了一个简单的选择排序算法实现过程,通过Java代码演示了如何对输入的整数数组进行升序排列。首先读取命令行参数作为待排序的数组元素,然后使用选择排序算法进行排序,并分别在排序前后打印数组。

public class NumSort {

public static void main(String[] args) {
// TODO 自动生成的方法存根
int[]a=new int[args.length];
for(int i=0;i<args.length;i++){
a[i]=Integer.parseInt(args[i]);
}
System.out.println("排序前:");
print(a);
selectionSort(a);
System.out.println("排序后:");
print(a);

}
private static void selectionSort(int[] a){
int k,temp;
for(int i=0;i<a.length;i++){
k=i;
for(int j=k+1;j<a.length;j++){
if(a[j]<a[k]){
k=j;
}
}
if(k!=i){
temp=a[i];
a[i]=a[k];
a[k]=temp;

}
}
}
private static void print(int[] a){
for(int i=0;i<a.length;i++){
System.out.print(a[i]+"");
}
System.out.println();
}

}

转载于:https://www.cnblogs.com/wlp1115/p/6545612.html

<template> <view class=“box”> <view class=“box-header”> <view class=“box-header-left”> <!-- 二期的对齐 --> </view> <view class=“box-header-right”> <text class=“box-header_label”>分值:</text> <text class=“box-header_value”>{{ item.indicatorScore }}</text> </view> </view> <view class=“box-title”> <view class=“box-title_left”> <text class=“sort”>O{{ item.numSort }}</text> <view class=“title”> <u–textarea v-model=“item.performanceIndicators” placeholder=“请输入关键目标” autoHeight height=“35” maxlength=“500” ></u–textarea> <view class=“type”> <text class=“typeName”>{{ item.typeName }}</text> <u-icon name=“arrow-down”></u-icon> </view> </view> </view> <view class=“box-title_right” :class=“{ arrowDrown: !item.show }” @click=“changeShow(item)”> <image src=“@/static/image/OKR/arrow-up.png” mode=“widthFix” /> </view> </view> <transition name=“slide-fade”> <view class=“box-list” v-show=“item.show”> <view class=“krBox” v-for=“(element, index) in item.krList” :key=“index” > <view class=“krBox-header”> <view class=“krBox-header-left”> <text class=“sort” >KR{{ item.numSort }}.{{ element.numSort }}</text > <u–textarea v-model=“element.quantitativeObjectives” placeholder=“请输入关键结果,格式:(通过xxx策略/措施),实现XX量化结果)” autoHeight height=“35” maxlength=“500” border=“surround” ></u–textarea> </view> <view class=“krBox-header_close”> <image src=“@/static/image/OKR/close.png” mode=“widthFix” /> </view> </view> <view class=“krBox-item”> <view class=“krBox-item_label”> <text>填报部门</text> </view> <view class=“krBox-item_value”> <u–input placeholder=“请选择填报部门” border=“surround” v-model=“element.fillDeptName” suffixIcon=“arrow-down” suffixIconStyle=“color: #C0C4CC;font-size: 18px;” ></u–input> </view> </view> </view> </view> </transition> </view> </template> <script> export default { props: { item: { type: Object, default: () => { return { id: “”, typeId: “”, typeName: “”, performanceIndicators: “”, numSort: 1, dataType: 0, indicatorScore: 0, krList: [], show: true, }; }, }, }, data() { return {}; }, methods: { changeShow(item) { item.show = !item.show; }, }, }; </script> <style lang=“scss” scoped> .box { background: #ffffff; border-radius: 16rpx; overflow: hidden; // padding: 20rpx; box-sizing: border-box; /* font-size: 30rpx; color: #303133; */ &-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8rpx; padding: 20rpx 20rpx 0; box-sizing: border-box; &_label { font-size: 26rpx; color: #909399; } &_value { font-size: 26rpx; color: #303133; } } &-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30rpx; padding-left: 20rpx; box-sizing: border-box; &_left { flex: 1; display: flex; align-items: center; justify-content: flex-start; .sort { background: #409eff; border-radius: 8rpx; padding: 0 12rpx; font-weight: 500; font-size: 30rpx; color: #ffffff; margin-right: 12rpx; } .title { position: relative; flex: 1; border: 1rpx solid #efefef; border-radius: 8rpx; .u-textarea { text-indent: 6em; } .type { position: absolute; top: 0; left: 10rpx; display: flex; align-items: center; height: 70rpx; .typeName { margin-right: 10rpx; } .u-icon { margin-top: 8rpx; } } } } &_right { width: 60rpx; display: flex; justify-content: center; align-items: center; transition: all 0.3s ease; image { width: 44rpx; } } .arrowDrown{ transform: rotate(180deg); } } &-list { } } } .krBox { padding: 24rpx 60rpx 32rpx 20rpx; box-sizing: border-box; border-top: 1rpx solid #dcdfe6; } </style> 完善样式,实现slide-fade,类似于折叠面板形式的展开收起效果
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值