C # loop App mobile phone number The exercise of the squad Leader

Source: Internet
Author: User
Tags clear screen

First question

20 Mobile phone number scrolling display randomly draw out a winning number;

static void BBB (string[] args)

{

string[] CellPhone = new string[] {"13012345678", "13109876543", "13287654678", "13309876789",

"13509878902", "13698374651", "13757893421", "13876561234", 13909876543 ",

"15034567438", "15111234795", "15894574839", "18210394857", "18302938475"};

Random rand = new Random ();

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

{

System.Threading.Thread.Sleep (100); Slow down a bit.

int sub = rand.             Next (cellphone.length); Randomly generates the subscript for an array.

string s = cellphone[sub]; The element values of the array are taken according to the subscript.

Console.clear (); Clear Screen

Console.WriteLine (s); Show

}

}

}

30 people vote, choose one out of 5 candidates.

int[] vote = new Int[5];

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

{

Console.Write ("Please" + (i+1) + "Students Vote (0-4):");

int temp = Convert.ToInt32 (Console.ReadLine ());

if (temp <0 | | temp >4)

{

Console.WriteLine ("Invalidated");

Continue

}

Else

{

vote[temp]++;

}

}

Calculate the final ticket. int max = 0, maxsub = 0;

for (int i=0;i<vote. length;i++)

{

Show the number of votes for each candidate. Console.WriteLine ("No." + (i + 1) + "Number of votes for candidates is:" + vote[i]);

Calculates the maximum value. if (Vote[i] > Max)

{max = vote[i];

Maxsub = i;

}

}

Displays the final result. Console.WriteLine ("Final poll Result:" + (maxsub+1) + "candidate elected, the number of votes is" +max+ "ticket. ");

}

}

}

C # loop App mobile phone number The exercise of the squad Leader

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.