注册账号 登录
小春网 返回首页

tree77heaven的个人空间 https://www.incnjp.com/?294237 [收藏] [复制] [分享] [RSS]

日志

codility2

已有 249 次阅读2017-3-13 17:18 |个人分类:codility|系统分类:学习

// you can also use imports, for example:
// import java.util.*;

// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");



class Solution2 {

public static void main(String[] args){

int A[]={1,2,3,-4,-6,-90};
int K=10;

int iK=0 ;
int tempiB[];
String retA="";
String retB="";
int i=0;



if (K==0||A.length==0||A.length==1){
tempiB=A;
}else{
iK=K % A.length;
if(iK==0){
tempiB=A;

}else{

retA=String.valueOf( A[0]);
for(i=1;i<A.length;i++){
retA=retA+","+A[i];

}

String tempB[]=retA.split(",");

// retB=retA.substring(retA.length()-(iK+(iK-1)), retA.length()) +","+ retA.substring(0,retA.length()-(iK+(iK-1))-1);

// String tempB[]=retB.split(",");
   tempiB=new int[tempB.length];
   int j=0;
for(i=0;i<tempB.length;i++){
if(i>=tempB.length-iK){
tempiB[j]=Integer.parseInt(tempB[i]);
j++;
}else{
tempiB[iK+i]=Integer.parseInt(tempB[i]);
}

}


}


}



System.out.println(iK);
// System.out.println(retA);

}

}



悲剧

无聊

震惊

支持

不解

超赞

愤怒

高兴

全部作者的其他最新日志

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册账号

小春网
常务客服微信
微信订阅号
手机客户端
扫一扫,查看更方便! 返回顶部