有文本如下,需要竖排版:
<现实>我的爱人(我的鸟的本名)</现实>
<现实>冰龙战士纯属虚构。如论真相,看我没有。如果真是如此,大可洋河一跃。</现实>
<真相>希伯来族本就没有。如论真相,请看厚颜。如果真是如此,洋河一跃真相大白。</真相>
<总标签>
123<标签>当年有一种族名曰“”。</标签>
123<标签>后来皇帝为了吃喝命令找到天地。</标签>
123<标签>后来天地找到了再到后来天地消失了。</标签>
123<标签>再到后来。</标签>
123<标签>我的命结束了。</标签>
123<标签>长生不老药找到了。</标签>
123<标签>再到后来,我的命没有了。</标签>
123<标签>再到后来,我的命有了。</标签>
123<标签>再到后来,我的命又有了。</标签>
123<标签>天下终于知道我的命真的没有了。</标签>
</总标签>
要求:尖括号中的要去掉,‘123’要算一个字。
Java代码如下:
package aannpk;
public class aa {
public static String whereMyTxt(String S , String s1 , String s2){
String r = new String("");
if (S.startsWith("123")) r = "123";
int i1 = S.indexOf(s1);
int i2 = S.indexOf(s2,i1+1);
int i3 = S.indexOf(s1,i2+1);
S = r.concat(S.substring(i2+1,i3));
return S;
}
public static void pai2ban3(String s13,String s12,String s11, String s10,String s9,String s8,String s7,String s6,String s5,String s4,String s3,String s2,String s1){
int highLine = 0;
if (s13.length()>highLine) highLine=s13.length();
if (s12.length()>highLine) highLine=s12.length();
if (s11.length()>highLine) highLine=s11.length();
if (s10.length()>highLine) highLine=s10.length();
if (s9.length()>highLine) highLine=s9.length();
if (s8.length()>highLine) highLine=s8.length();
if (s7.length()>highLine) highLine=s7.length();
if (s6.length()>highLine) highLine=s6.length();
if (s5.length()>highLine) highLine=s5.length();
if (s4.length()>highLine) highLine=s4.length();
if (s3.length()>highLine) highLine=s3.length();
if (s2.length()>highLine) highLine=s2.length();
if (s1.length()>highLine) highLine=s1.length();
int lineCo = s11.length();
int i;
System.out.println("<table>");
for (i=0;i<lineCo;i++) {
System.out.print("<tr>");
if (s13.startsWith("123") & i<3) {
if (i == 0) {
System.out.print("<td>123</td>");
}
else {
System.out.print("<td></td>");
}
}
if ((s13.startsWith("123") & i>2) | s13.startsWith("123") != true)
{
if (i<s13.length())
{
System.out.print("<td>" + s13.charAt(i)+"</td>");
}
else
{
System.out.print("<td></td>");
}
}
if (s12.startsWith("123") & i<3) {
if (i == 0) {
System.out.print("<td>123</td>");
}
else {
System.out.print("<td></td>");
}
}
if ((s12.startsWith("123") & i>2) | s12.startsWith("123") != true)
{
if (i<s12.length())
{
System.out.print("<td>" + s12.charAt(i)+"</td>");
}
else
{
System.out.print("<td></td>");
}
}
if (s11.startsWith("123") & i<3) {
if (i == 0) {
System.out.print("<td>123</td>");
}
else {
System.out.print("<td></td>");
}
}
if ((s11.startsWith("123") & i>2) | s11.startsWith("123") != true)
{
if (i<s11.length())
{
System.out.print("<td>" + s11.charAt(i)+"</td>");
}
else
{
System.out.print("<td></td>");
}
}
if (s10.startsWith("123") & i<3) {
if (i == 0) {
System.out.print("<td>123</td>");
}
else {
System.out.print("<td></td>");
}
}
if ((s10.startsWith("123") & i>2) | s10.startsWith("123") != true)
{
if (i<s10.length())
{
System.out.print("<td>" + s10.charAt(i)+"</td>");
}
else
{
System.out.print("<td></td>");
}
}
if (s9.startsWith("123") & i<3) {
if (i == 0) {
System.out.print("<td>123</td>");
}
else {
System.out.print("<td></td>");
}
}
if ((s9.startsWith("123") & i>2) | s9.startsWith("123") != true)
{
if (i<s9.length())
{
System.out.print("<td>" + s9.charAt(i)+"</td>");
}
else
{
System.out.print("<td></td>");
}
}
if (s8.startsWith("123") & i<3) {
if (i == 0) {
System.out.print("<td>123</td>");
}
else {
System.out.print("<td></td>");
}
}
if ((s8.startsWith("123") & i>2) | s8.startsWith("123") != true)
{
if (i<s8.length())
{
System.out.print("<td>" + s8.charAt(i)+"</td>");
}
else
{
System.out.print("<td></td>");
}
}
if (s7.startsWith("123") & i<3) {
if (i == 0) {
System.out.print("<td>123</td>");
}
else {
System.out.print("<td></td>");
}
}
if ((s7.startsWith("123") & i>2) | s7.startsWith("123") != true)
{
if (i<s7.length())
{
System.out.print("<td>" + s7.charAt(i)+"</td>");
}
else
{
System.out.print("<td></td>");
}
}
if (s6.startsWith("123") & i<3) {
if (i == 0) {
System.out.print("<td>123</td>");
}
else {
System.out.print("<td></td>");
}
}
if ((s6.startsWith("123") & i>2) | s6.startsWith("123") != true)
{
if (i<s6.length())
{
System.out.print("<td>" + s6.charAt(i)+"</td>");
}
else
{
System.out.print("<td></td>");
}
}
if (s5.startsWith("123") & i<3) {
if (i == 0) {
System.out.print("<td>123</td>");
}
else {
System.out.print("<td></td>");
}
}
if ((s5.startsWith("123") & i>2) | s5.startsWith("123") != true)
{
if (i<s5.length())
{
System.out.print("<td>" + s5.charAt(i)+"</td>");
}
else
{
System.out.print("<td></td>");
}
}
if (s4.startsWith("123") & i<3) {
if (i == 0) {
System.out.print("<td>123</td>");
}
else {
System.out.print("<td></td>");
}
}
if ((s4.startsWith("123") & i>2) | s4.startsWith("123") != true)
{
if (i<s4.length())
{
System.out.print("<td>" + s4.charAt(i)+"</td>");
}
else
{
System.out.print("<td></td>");
}
}
if (s3.startsWith("123") & i<3) {
if (i == 0) {
System.out.print("<td>123</td>");
}
else {
System.out.print("<td></td>");
}
}
if ((s3.startsWith("123") & i>2) | s3.startsWith("123") != true)
{
if (i<s3.length())
{
System.out.print("<td>" + s3.charAt(i)+"</td>");
}
else
{
System.out.print("<td></td>");
}
}
if (s2.startsWith("123") & i<3) {
if (i == 0) {
System.out.print("<td>123</td>");
}
else {
System.out.print("<td></td>");
}
}
if ((s2.startsWith("123") & i>2) | s2.startsWith("123") != true)
{
if (i<s2.length())
{
System.out.print("<td>" + s2.charAt(i)+"</td>");
}
else
{
System.out.print("<td></td>");
}
}
if (s1.startsWith("123") & i<3) {
if (i == 0) {
System.out.print("<td>123</td>");
}
else {
System.out.print("<td></td>");
}
}
if ((s1.startsWith("123") & i>2) | s1.startsWith("123") != true)
{
if (i<s1.length())
{
System.out.print("<td>" + s1.charAt(i)+"</td>");
}
else
{
System.out.print("<td></td>");
}
}
System.out.println("</tr>");
}
System.out.println("</table>");
}
public static void main(String[] args) {
String S = new String("<现实>我的爱人(我的鸟的本名)</现实>");
S = whereMyTxt(S,"<",">");
String Line1 = new String(S);
S = "<现实>冰龙战士纯属虚构。如论真相,看我没有。如果真是如此,大可洋河一跃。</现实>";
S = whereMyTxt(S,"<",">");
String Line2 = new String(S);
S = "<真相>希伯来族本就没有。如论真相,请看厚颜。如果真是如此,洋河一跃真相大白。</真相>";
S = whereMyTxt(S,"<",">");
String Line3 = new String(S);
S = "<总标签>";
S = "123<标签>当年有一种族名曰“”。</标签>";
S = whereMyTxt(S,"<",">");
String Line4 = new String(S);
S = "123<标签>后来皇帝为了吃喝命令找到天地。</标签>";
S = whereMyTxt(S,"<",">");
String Line5 = new String(S);
S = "123<标签>后来天地找到了再到后来天地消失了。</标签>";
S = whereMyTxt(S,"<",">");
String Line6 = new String(S);
S = "123<标签>再到后来。</标签>";
S = whereMyTxt(S,"<",">");
String Line7 = new String(S);
S = "123<标签>我的命结束了。</标签>";
S = whereMyTxt(S,"<",">");
String Line8 = new String(S);
S = "123<标签>长生不老药找到了。</标签>";
S = whereMyTxt(S,"<",">");
String Line9 = new String(S);
S = "123<标签>再到后来,我的命没有了。</标签>";
S = whereMyTxt(S,"<",">");
String Line10 = new String(S);
S = "123<标签>再到后来,我的命有了。</标签>";
S = whereMyTxt(S,"<",">");
String Line11 = new String(S);
S = "123<标签>再到后来,我的命又有了。</标签>";
S = whereMyTxt(S,"<",">");
String Line12 = new String(S);
S = "123<标签>天下终于知道我的命真的没有了。</标签>";
S = whereMyTxt(S,"<",">");
String Line13 = new String(S);
S = "</总标签>";
pai2ban3(Line13,Line12,Line11,Line10,Line9,Line8,Line7,Line6,Line5,Line4,Line3,Line2,Line1);
}
}
运行结果:
<table>
<tr><td>123</td><td>123</td><td>123</td><td>123</td><td>123</td><td>123</td><td>123</td><td>123</td><td>123</td><td>123</td><td>希</td><td>冰</td><td>我</td></tr>
<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>伯</td><td>龙</td><td>的</td></tr>
<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>来</td><td>战</td><td>爱</td></tr>
<tr><td>天</td><td>再</td><td>再</td><td>再</td><td>长</td><td>我</td><td>再</td><td>后</td><td>后</td><td>当</td><td>族</td><td>士</td><td>人</td></tr>
<tr><td>下</td><td>到</td><td>到</td><td>到</td><td>生</td><td>的</td><td>到</td><td>来</td><td>来</td><td>年</td><td>本</td><td>纯</td><td>(</td></tr>
<tr><td>终</td><td>后</td><td>后</td><td>后</td><td>不</td><td>命</td><td>后</td><td>天</td><td>皇</td><td>有</td><td>就</td><td>属</td><td>我</td></tr>
<tr><td>于</td><td>来</td><td>来</td><td>来</td><td>老</td><td>结</td><td>来</td><td>地</td><td>帝</td><td>一</td><td>没</td><td>虚</td><td>的</td></tr>
<tr><td>知</td><td>,</td><td>,</td><td>,</td><td>药</td><td>束</td><td>。</td><td>找</td><td>为</td><td>种</td><td>有</td><td>构</td><td>鸟</td></tr>
<tr><td>道</td><td>我</td><td>我</td><td>我</td><td>找</td><td>了</td><td></td><td>到</td><td>了</td><td>族</td><td>。</td><td>。</td><td>的</td></tr>
<tr><td>我</td><td>的</td><td>的</td><td>的</td><td>到</td><td>。</td><td></td><td>了</td><td>吃</td><td>名</td><td>如</td><td>如</td><td>本</td></tr>
<tr><td>的</td><td>命</td><td>命</td><td>命</td><td>了</td><td></td><td></td><td>再</td><td>喝</td><td>曰</td><td>论</td><td>论</td><td>名</td></tr>
<tr><td>命</td><td>又</td><td>有</td><td>没</td><td>。</td><td></td><td></td><td>到</td><td>命</td><td>“</td><td>真</td><td>真</td><td>)</td></tr>
<tr><td>真</td><td>有</td><td>了</td><td>有</td><td></td><td></td><td></td><td>后</td><td>令</td><td>”</td><td>相</td><td>相</td><td></td></tr>
<tr><td>的</td><td>了</td><td>。</td><td>了</td><td></td><td></td><td></td><td>来</td><td>找</td><td>。</td><td>,</td><td>,</td><td></td></tr>
</table>