Print the following figure using code and use a triangle consisting of letters

Source: Internet
Author: User

The implementation is required to print out the form: idea: a forward, a reverse starts from the second of the array, and the implementation of a in the middle of Java is as follows: [java] package org. wxp. sort; import junit. framework. testCase; public class Sort_02 extends TestCase {private String [] arr = {"a", "B", "c", "d", "e", "f ", "g", "h", "I", "j", "k", "l", "m", "n", "o", "p ", "q", "r", "s", "t", "u", "v", "w", "x", "y ", "z"}; public void test () {for (int I = 0; I <arr. length; I ++) {for (int j = arr. length; j> I; j --) {System. out. print ("") ;}for (int j = I; j> 0; j --) {// sort the Output System in reverse order. out. print (arr [j]);} System. out. print (arr [0]); // always centers around the first value of the array for (int j = 0; j <I; j ++) {// Output System in a forward arrangement. out. print (arr [j + 1]);} System. out. println (""); // line feed }}}

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.