-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 に答える