赞
踩
凉凉夜色为我思念成河
import java.util.*; public class Main { public static void main(String[] args){ Scanner in = new Scanner(System.in); String ii = in.nextLine(); int length = Integer.parseInt(ii); String s = in.nextLine(); String[] strList = s.split("-"); StringBuffer sb = new StringBuffer(); sb.append(strList[0]).append("-"); StringBuffer action = new StringBuffer(); for (int i = 1; i<strList.length; i++) { action.append(strList[i]); } int size = action.length() / length; for (int i = size; i > 0; i--) { String substring = action.substring(0, length); char[] chars = substring.toCharArray(); int lower = 0; int higher = 0; for (char aChar : chars) { //if (aChar == '@') continue; if (aChar >= 'A' && aChar <= 'Z') { higher ++; } else if (aChar >= 'a' && aChar <= 'z') { lower ++; } } if (lower > higher) { sb.append(substring.toLowerCase()).append("-"); } else if (lower < higher){ sb.append(substring.toUpperCase()).append("-"); } else { sb.append(substring).append("-"); } action.delete(0, 3); } sb.append(action); if (sb.charAt(sb.length()-1) == '-') { sb.deleteCharAt(sb.length()-1); } System.out.println(sb); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。