-2
// The "PalinDrome" class.
import java.awt.*;
import hsa.Console;

public class PalinDrome
{
    static Console c;           // The output console

    public static void main (String[] args)
    {
        c = new Console ();

        c.println("Please enter a word");
           String word = c.readLine ();
        int i;
        int num = word.length ();
        String str = "";
        for (i = num - 1 ; i >= 0 ; i--)
            str = str + word.charAt (i);
        if (str.equals (word))
            c.println (word + " is a palindrome");
        else
            c.println (word + " is not a palindrome");

        str.equalsIgnoreCase(word);




        // Place your program here.  'c' is the output console
    } // main method
} // PalinDrome class

作为考试项目的一部分,我创建了一个回文程序。我想让字母以三角形的形状出现。你对我该怎么做有什么建议吗?

4

1 回答 1

0

用户根据字符串的长度构建string.format一个三角形。使用另一个循环遍历字符串并在每组字符之前/之后附加适当的间距  \t\nfor

于 2013-01-23T09:56:36.133 回答