Randomly add data between 1-to the arraylist array.

Source: Internet
Author: User
Using system; using system. collections. generic; using system. LINQ; using system. text; using system. collections; namespace consoleapplication2 {class program {// randomly add data between 1 and to the static void main (string [] ARGs) {arraylist arrlist = new arraylist (); // declare an array random ran = new random (); // define a pseudo-random number generator while (true) {// If the arrlist array contains more than 100 elements, the arrlist elements are output, and then the program (return) if (arrlist. count & gt; = 100) {Arrlist. sort (); // sort arrlist data in ascending order. foreach (INT s in arrlist) {console. write (S + "");} console. readkey (); return;} int random = ran. next (1,101); // returns a random number between 1 and if (! Arrlist. Contains (random) {arrlist. Add (random );}}}}}


Split the elements of the array by dividing lines

Namespace consoleapplication2 {class program {static void main (string [] ARGs) {// output you | I | his string [] arr = {"you", "I ", "He"}; string S = NULL; For (INT I = 0; I <arr. length; I ++) {if (I = arr. length-1) {S = S + arr [I];} else {S = S + arr [I] + "|" ;}} console. writeline (s); console. readkey ();}}}


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.