reorder在java中什么意思_reOrderArray.java

import java.lang.reflect.Array;

import java.util.Arrays;

/**

* Created by dell on 2018/1/5.

*/

public class reOrderArray {

//14ms 10K AC

//空间和时间均不理想

public void reOrderArray(int [] array) {

//遍历一次数组 得到奇数和偶数的数量

//O(n)

int[] a= Arrays.copyOf(array,array.length);

int odd=0,count=0;

for(int index=0;index

if((array[index]&1)==1)

odd++;

}

//再遍历一次数组

for(int index=0;index

{

if((a[index]&1)==1) {

array[count] = a[index];

count++;

}

else

{

array[odd]=a[index];

odd++;

}

}

}

public void reOrderArray(int [] array,int k){

int odd=0;

for(int index=0;index

//奇数

if((array[index]&1)==1)

{

int temp=array[index];

//从odd处到index-1处,所有元素(都是偶数)向后挪动一个位置

for(int i=index;i>odd;i--){

array[index]=array[index-1];

}

array[odd+1]=array[odd];

array[odd]=temp;

odd++;

}

}

}

public static void main(String[] args) {

int[] a={1,3,5,6,8,9,2,4};

reOrderArray orderArray=new reOrderArray();

orderArray.reOrderArray(a,1);

System.out.println();

}

}

一键复制

编辑

Web IDE

原始数据

按行查看

历史

FAILED: CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o /usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_IOSTREAMS_DYN_LINK -DGFLAGS_IS_A_DLL=0 -I../cartographer -I. -I../ -isystem /usr/include/eigen3 -isystem /usr/include/lua5.2 -O3 -DNDEBUG -pthread -fPIC -Wall -Wpedantic -Werror=format-security -Werror=missing-braces -Werror=reorder -Werror=return-type -Werror=switch -Werror=uninitialized -O3 -DNDEBUG -pthread -fPIC -Wall -Wpedantic -Werror=format-security -Werror=missing-braces -Werror=reorder -Werror=return-type -Werror=switch -Werror=uninitialized -O3 -DNDEBUG -std=gnu++11 -MD -MT CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o -MF CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o.d -o CMakeFiles/cartographer.transform.timestamped_transform_test.dir/cartographer/transform/timestamped_transform_test.cc.o -c ../cartographer/transform/timestamped_transform_test.cc In file included from ../cartographer/transform/timestamped_transform_test.cc:17: ../cartographer/transform/timestamped_transform.h:21:10: fatal error: cartographer/transform/proto/timestamped_transform.pb.h: No such file or directory 21 | #include "cartographer/transform/proto/timestamped_transform.pb.h" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. [44/380] Building CXX object CMakeFiles/cartographer.sensor.internal.voxel_filter_test.dir/cartographer/sensor/internal/voxel_filter_test.cc.o
07-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值