Skip to content

Instantly share code, notes, and snippets.

@blackraccoon000
Created April 11, 2013 10:42
Show Gist options
  • Save blackraccoon000/5362401 to your computer and use it in GitHub Desktop.
Save blackraccoon000/5362401 to your computer and use it in GitHub Desktop.
/**
*Copyright (c) 2013/04/11 Yutaka Fujii
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/
public class DiversingParam {
// 判定を入れたい
// 範囲選択時の実行場所
String[] run(String argument){
String[] originNum = SplitSlashMode.splitPartition(argument);
for(int i=0;i<originNum.length;i++){
System.out.println(originNum[i]);
}
return originNum;
}
}
/**
*Copyright (c) 2013/04/11 Yutaka Fujii
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/
public class Main {
public static void main(String[] args) {
// write your code here
String argument = "101-120";
// 範囲選択時
DiversingParam dPa = new DiversingParam();
dPa.run(argument);
}
}
/**
*Copyright (c) 2013/04/11 Yutaka Fujii
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/
public class SplitSlashMode {
static String[] splitPartition(String argument){
String[] spPart = argument.split("-");
int startNum = Integer.valueOf(spPart[0]);
int finishNum = Integer.valueOf(spPart[spPart.length-1]);
int count = finishNum - startNum+1;
String data[];
data = SplitSlashMode.value(count);
// "-"で分割、始まりから終わりまで数字列挙
for(int i=startNum;i<finishNum+1;i++){
data[i-startNum] = String.valueOf(i);
}
return data;
}
// 列挙した数字を格納する配列を作成
private static String[] value(int partitionNum){
String[] stBox = new String[partitionNum];
return stBox;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment