Random number Scissors

Source: Internet
Author: User

1.

 intp =1; intS1 =0, SHU1 =0;  while(true) {Random R=NewRandom (); intShu = R.next (3); Console.WriteLine ("0-Burden, 1-scissors, 2-hammerhead"); Console.WriteLine ("Please enter any one of the 0,1,2 three numbers:"); ints =int.                                Parse (Console.ReadLine ()); if(s = =0) {Console.WriteLine ("you're a burden ."); }                if(s = =1) {Console.WriteLine ("you out of scissors ."); }                if(s = =2) {Console.WriteLine ("you're a hammer ."); }                if(Shu = =0) {Console.WriteLine ("a computer is a burden"); }                if(Shu = =1) {Console.WriteLine ("Computer out Scissors"); }                if(Shu = =2) {Console.WriteLine ("computer out of the hammer"); }                if(s = =Shu) {Console.WriteLine ("This council is a draw ."); }                if(s = =0&& Shu = =2) || (s = =1&& Shu = =0) || (s = =2&& Shu = =1) {Console.WriteLine ("This council, you won."); S1= S1 +1; }                if(Shu = =0&& s = =2) || (Shu = =1&& s = =0) || (Shu = =2&& s = =1) {Console.WriteLine ("the computer won the game."); SHU1= Shu1 +1; } Console.WriteLine ("Number of games:"+ P +"Bureau"); P+=1; if(p = =4)                {                     Break;            } console.readline ();            } console.readline (); if(s1>shu1) {Console.WriteLine ("congratulations on your 3 innings ."+s1+"Victory wins"); }            if(S1 <shu1) {Console.WriteLine ("I'm sorry you're 3 innings ."+shu1+"defeat to the computer"); }            if(s1==shu1) {Console.WriteLine ("Draw"); }

2.

            intfenshu1=0, fenshu2=0;  for(inti =1; I <=3; i++) {Random R=NewRandom (); intShu = R.next (3); Console.WriteLine ("0-Burden, 1-scissors, 2-hammerhead"); Console.WriteLine ("Please enter any one of the 0,1,2 three numbers:"); ints =int.                Parse (Console.ReadLine ()); if(s = =0) {Console.WriteLine ("you're a burden ."); }                if(s = =1) {Console.WriteLine ("you out of scissors ."); }                if(s = =2) {Console.WriteLine ("you're a hammer ."); }                if(Shu = =0) {Console.WriteLine ("a computer is a burden"); }                if(Shu = =1) {Console.WriteLine ("Computer out Scissors"); }                if(Shu = =2) {Console.WriteLine ("computer out of the hammer"); }                if(s = =Shu) {Console.WriteLine ("This council is a draw ."); }                if(s = =0&& Shu = =2) || (s = =1&& Shu = =0) || (s = =2&& Shu = =1) {Console.WriteLine ("This council, you won."); FENSHU1= Fenshu1 +1; }                if(Shu = =0&& s = =2) || (Shu = =1&& s = =0) || (Shu = =2&& s = =1) {Console.WriteLine ("the computer won the game."); FENSHU2= Fenshu2 +1;            } console.readline (); }                     if(Fenshu1 >fenshu2) {Console.WriteLine ("congratulations on your success! "); }            if(Fenshu1 <fenshu2) {Console.WriteLine ("I'm sorry you lost! "); }            if(FENSHU1 = =fenshu2) {Console.WriteLine ("Draw"); }

Random number Scissors

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.