java-Array Exercise 4

Source: Internet
Author: User

16. Write Java applications as required. Write a main class called Test, with only one main method in the class;

A one-dimensional integer array of size 50 is defined in the main method, the array is named X, and the array holds {1,

3,5,..., 99} Outputs all elements of this array, each output 10 lines, and one in the Main method

A two-dimensional character array of size 10*10, with the array named Y, the positive and negative diagonal on the ' * ', the rest

The position is ' # '; outputs all elements of this array.

int [] x=new int[50];

Char [[] y=new char[10][10];

for (int i=0;i<50;i++)

{

x[i]=2*i+1;

if (i==10| | i==20| | i==30| | I==40)

{

System. out. println ();

}

System. out. Print ("" +x[i]);

}

System. out. println ();

for (int n=0;n<10;n++)

{

for (int z=0;z<10;z++)

{

if (z==n| | z== (9-n))

{

y[n][z]= ' * ';

}

Else

{

y[n][z]= ' # ';

}

}

}

System. out. println ();

for (char[] temp:y)

{

for (char temp1:temp)

{

System. out. Print (temp1+ "");

}

System. out. println ();

}

java-Array Exercise 4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.