C # Simple example of handling scissors problems (non-form) _c# Tutorials

Source: Internet
Author: User
Tags readline

C # Simple instances of handling scissors problems (non-form)

Scissors, 5 innings, 3 wins, requires the use of public variables.

    Namespace structure Body Review _ Common variable {class Program {public int rz=0;

 

    public int dz = 0;

      public string BJ (int a, int b) {int d = a-b; if (d==-2| |

      D==1) {return "person"; else if (d==2| |

      D==-1) {return "computer";

      else {return "and";

      } static void Main (string[] args) {Random SJ = new Random ();

      Program Zdy=new ();

        while (Zdy.rz < 3 && Zdy.dz < 3) {Console.WriteLine ("Please enter the number of scissors stone cloth (1 for scissors, 2 for stone, 3 for cloth):"); int a = Int.

        Parse (Console.ReadLine ()); int b = SJ.

        Next (1,4);

        String JG = ZDY.BJ (A, b);

            Switch (JG) {case "person": zdy.rz++;

            Console.WriteLine ("You win this Council");

          Break

            Case "Computer": zdy.dz++;

            Console.WriteLine ("Computer wins in this Council");

          Break Case "and": Console.writelINE ("This council draws");

        Break

      } if (Zdy.rz > Zdy.dz) {Console.WriteLine ("You Won");

 

      else {Console.WriteLine ("You Lost");

    } console.readline ();
 }

  }

}

Above this C # processing scissors problem Simple example (non-form) is a small series to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.

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.