Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Why PE 希望JAVA的来看一下?import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // StringBuilder sb = new StringBuilder(); StringBuilder ans = new StringBuilder(); int len = 0; while (sc.hasNext()) { String s = sc.next(); if (s.equals("<br>")) { if (ans.substring(ans.length() - 1, ans.length()).equals(" ")) ans = new StringBuilder(ans.substring(0, ans.length() - 1)); ans.append("\n"); // sb.delete(0, sb.length()); len = 0; continue; } else if (s.equals("<hr>")) { s = ""; for (int i = 0; i < 80; ++i) s += "-"; if (ans.length() == 0) ans.append(s).append("\n"); else if (ans.charAt(ans.length() - 1) == '\n') ans.append(s).append("\n"); else ans.append("\n").append(s).append("\n"); len = 0; continue; } else { len += s.length(); if (len == 80) { len = 0; ans.append(s).append("\n"); } else if (len < 80) ans.append(s).append(" "); else { len = s.length(); ans.delete(ans.length() - 1, ans.length()); ans.append("\n").append(s).append(" "); } len++; } } if (ans.substring(ans.length() - 1, ans.length()).equals(" ")) ans = ans.delete(ans.length() - 1, ans.length()); System.out.println(ans.toString()); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator