标签:problem ret for value ide bsp list toc int
时限:1000 MS | 内存限制:10000 K | |
提交材料共计: 114762 | 接受: 45919 |
描述
输入
输出量
样本输入
10 6 AACATGAAGG TTTTGGCCAA TTTGGCCAAA GATCAGATTT CCCGGGGGGA ATCGATGCAT
样本输出
CCCGGGGGGA AACATGAAGG GATCAGATTT ATCGATGCAT TTTTGGCCAA TTTGGCCAAA
来源
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); List<Element> list = new ArrayList<Element>(); List<Integer>levelList=new ArrayList<Integer>(); int i,j, level, elementNum; scanner.nextInt(); elementNum = scanner.nextInt(); int flag = 0; for (i = 0; i < elementNum + 1; i++) { String element = scanner.nextLine(); if (flag == 0) { flag = 1; continue; } char[] elementArray = element.toCharArray(); level = getLevel(elementArray); Element element1 = new Element(); element1.setValue(element); element1.setLevel(level); list.add(element1); levelList.add(level); } Object[] levelArray = levelList.toArray(); Arrays.sort(levelArray); for(i=0;i<levelArray.length;i++){ for(j=0;j<list.size();j++){ if(list.get(j).getLevel()==levelArray[i]){ System.out.println(list.get(j)); // System.out.println(list.get(j).getValue()); list.remove(j); break; } } } } private static int getLevel(char[] elementArray) { int i, j, level = 0, len = elementArray.length; for (i = 0; i < len - 1; i++) { for (j = i + 1; j < len; j++) { if (elementArray[i] > elementArray[j]) { level++; } } } return level; } } class Element { private String value; private Integer level; public String getValue() { return value; } void setValue(String value) { this.value = value; } public Integer getLevel() { return level; } void setLevel(Integer level) { this.level = level; } @Override public String toString() { return "Element{" + "value=‘" + value + ‘\‘‘ + ", level=" + level + ‘}‘; } }
不知道哪里错了
标签:problem ret for value ide bsp list toc int
原文地址:https://www.cnblogs.com/yangzihong/p/11918828.html