Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package workplace;
- import com.google.common.base.Joiner;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.List;
- public class Main {
- public static void main(String[] args) {
- final int depth = 6;
- final List<Integer> itemsList = new ArrayList<Integer>();
- for (int item=1;item<=depth;item++) {
- itemsList.add(item);
- if (itemsList.size()%2!=0) {
- Collections.sort(itemsList);
- } else {
- Collections.sort(itemsList, Collections.reverseOrder());
- }
- System.out.println(Joiner.on("-").join(itemsList));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement