展开全部
package test;
public class Test
{
public static void main(String[] args)
{
String separator = System.getProperty("line.separator");
String str = "天生我才必有用" + separator + "千金散尽还复来" + separator + "这是最最最长长长的一行哦" + separator + "最短的行";
String[] strArray = str.split(separator);
int maxLine = 0;
String tmpStr = null;
for (int i = 0; i < strArray.length; i++)
{
if (strArray[i].length() > maxLine)
{
maxLine = strArray[i].length();
}
}
for (int j = 0; j < maxLine; j++)
{
for (int i = 0; i < strArray.length; i++)
{
if (j >= strArray[i].length())
{
tmpStr = "\t ";
}
else
{
tmpStr = "\t" + strArray[i].charAt(j);
}
System.out.print(tmpStr);
}
System.out.println("");
}
}
}
展开全部
public class test1 {
public static void main(String[] args) {
String one = "天生我材必有用";
String two = "千金易散还复来你好";
for (int i =0; i<one.length(); i++) {
System.out.print(one.substring(i, i+1));
for (int j=0; j<two.length(); j++) {
if (i==j) {
System.out.println(two.substring(j, j+1));
if (i==one.length()-1) {
for (int a=j+1; a<two.length(); a++) {
System.out.println(" "+two.substring(a, a+1));
}
}
}
}
}
}
}
我去,本来我是先回答的。发现你还说了每列字数不一样,又改了一下,结果被抢了...
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询