How do I print this pattern?Can anyone tell me the conditions(if statement)?

Matix

I don't know how to print the second and third row.Please help.

****    
*  *  
*  * 
****

for(i=1;i<=n;i++)  
{  
if (i==1)||(i==n)  
{  
for(j=1;j<=n;j++)  
System.out.print(j);  
}  
else{  
//dont know
Matix
thank you but no thank you!
class patter
    {
        public static void main(int n)
        {
            int i,j;
            for(i=1;i<=n;i++)
            {
                for(j=1;j<=n;j++)
                if(i==1||i==n)
                System.out.print("*");
                else
                {
                    if(j==1||j==n)
                    System.out.print("*");
                    else
                    System.out.print(" ");

                }
                System.out.println();
            }
        }
    }

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How do I tell which guard statement failed?

分類Dev

Would anyone please tell me what is wrong with my CSS file? When i call the primary color, it doesn't show in my html

分類Dev

Would anyone please tell me what is wrong with my CSS file? When i call the primary color, it doesn't show in my html

分類Dev

Whe I use the react route 4 history, but the console gives the follow warning. Can anyone tell me the reason?

分類Dev

How can I tell Selenium to press cancel on a print popup?

分類Dev

How can I tell Selenium to press cancel on a print popup?

分類Dev

How do I tell the `date` command to only show the time?

分類Dev

How do I tell GCC asm that an input register is clobbered?

分類Dev

How do I tell mono where to find a library?

分類Dev

How do I tell Pyinstaller to use an .EXE thats in the Scripts folder?

分類Dev

How do I tell if a Windows 8.1 Product Keys is an OEM key?

分類Dev

How do I tell notmuch to scan folders for new messages?

分類Dev

How do I tell Windows to keep internal disks offline?

分類Dev

How do I tell if a command is running or waiting for user input?

分類Dev

Can anyone explain to me how this script works?

分類Dev

How do I correctly print this triangle of characters?

分類Dev

How do I print the result of a command with 'echo'?

分類Dev

How do I print the matched string?

分類Dev

How do I print date data with bash

分類Dev

How do I print hyphens if a variable is empty?

分類Dev

How do I print with the screen stylesheet?

分類Dev

How do I print text in italics in Python?

分類Dev

How do I have to read the following statement?

分類Dev

How do I check if a variable exists in an 'if' statement?

分類Dev

Can anyone tell me which arguments will execute in Java if they are entered from both command prompt and the main method?

分類Dev

I have a problem with my table program. Could one tell me how to solve it?

分類Dev

In F#, how do I tell if an object is an Async<_>, and how can I cast it to an Async<_>?

分類Dev

Can you tell me how to use InvokeScriptTransaction

分類Dev

Number guessing game. field2 not displaying anything. Anyone can tell me what is wrong here?

Related 関連記事

  1. 1

    How do I tell which guard statement failed?

  2. 2

    Would anyone please tell me what is wrong with my CSS file? When i call the primary color, it doesn't show in my html

  3. 3

    Would anyone please tell me what is wrong with my CSS file? When i call the primary color, it doesn't show in my html

  4. 4

    Whe I use the react route 4 history, but the console gives the follow warning. Can anyone tell me the reason?

  5. 5

    How can I tell Selenium to press cancel on a print popup?

  6. 6

    How can I tell Selenium to press cancel on a print popup?

  7. 7

    How do I tell the `date` command to only show the time?

  8. 8

    How do I tell GCC asm that an input register is clobbered?

  9. 9

    How do I tell mono where to find a library?

  10. 10

    How do I tell Pyinstaller to use an .EXE thats in the Scripts folder?

  11. 11

    How do I tell if a Windows 8.1 Product Keys is an OEM key?

  12. 12

    How do I tell notmuch to scan folders for new messages?

  13. 13

    How do I tell Windows to keep internal disks offline?

  14. 14

    How do I tell if a command is running or waiting for user input?

  15. 15

    Can anyone explain to me how this script works?

  16. 16

    How do I correctly print this triangle of characters?

  17. 17

    How do I print the result of a command with 'echo'?

  18. 18

    How do I print the matched string?

  19. 19

    How do I print date data with bash

  20. 20

    How do I print hyphens if a variable is empty?

  21. 21

    How do I print with the screen stylesheet?

  22. 22

    How do I print text in italics in Python?

  23. 23

    How do I have to read the following statement?

  24. 24

    How do I check if a variable exists in an 'if' statement?

  25. 25

    Can anyone tell me which arguments will execute in Java if they are entered from both command prompt and the main method?

  26. 26

    I have a problem with my table program. Could one tell me how to solve it?

  27. 27

    In F#, how do I tell if an object is an Async<_>, and how can I cast it to an Async<_>?

  28. 28

    Can you tell me how to use InvokeScriptTransaction

  29. 29

    Number guessing game. field2 not displaying anything. Anyone can tell me what is wrong here?

ホットタグ

アーカイブ