C # capture your skills and practice it. If you do not need it, you can write it yourself. Practice it more and wait for improvement.

Source: Internet
Author: User
Using system; namespace z1_jiu {class z1_jiu {public static void main () {string [] person; int personnum; initperson (Out person, out personnum); z1_jiu (person, personnum ); console. readkey ();} public static void initperson (out string [] person, out int personnum) {bool flag = true; personnum = 0; // check the number of students while (FLAG) {try {console. write ("Enter the number of people who want to capture the cursor:"); personnum = int. parse (console. readline (); flag = false;} catch {console. writeline ("enter a non-number, enter it again") ;}} person = new string [personnum]; // check that the name is not empty for (INT I = 0; I <personnum; I ++) {console. write ("enter the name of the {0} person:", I + 1); flag = true; while (FLAG) {person [I] = console. readline (); If (person [I] = "" | person [I] = NULL) console. write ("no name is entered. Please enter the name of the {0} person again:", I + 1); else flag = false ;}}} public static void z1_jiu (string [] person, int personnum) {console. writeline ("start to capture logs... "); system. random ran = new random (); For (INT I = 0; I <personnum; I ++) {// a random number that cannot exceed the length of the current array is generated at a time, the length of the array is reduced by 1 each time; int rannow = ran. next (personnum-I); console. writeline ("the result of the {0} capture is: {1}", I + 1, person [rannow]); // reduce the length of the array by 1 each time; delperson (ref person, rannow) ;}} public static void delperson (ref string [] person, int rannow) {string [] tempperson = new string [person. length-1]; // After the obtained random number, move one forward. For (INT I = rannow; I <(person. length-1); I ++) {person [I] = person [I + 1];} // reduce the array length by 1 each time; for (Int J = 0; j <person. length-1; j ++) {tempperson [J] = person [J] ;}person = tempperson ;}}}

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.