Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Matchstick

using System.IO;
using System;

class Program
{
    static void Main()
    {
        int s=21,user,computer,n=0;
        while(s>=1)
        {
            if(s==1)
            {   Console.WriteLine("computer won the game");
                
                break;
            }
            
            user= Convert.ToInt32(Console.ReadLine());
            
            if(user>4)
            {
                Console.WriteLine("invalid");
            }
            else
            {
                Console.WriteLine("user's turn= "+user);
                computer=5-user;
                Console.WriteLine("computer's turn= "+computer);              
                n+=(user+computer);
            }
            s=21-n;
        }
    }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.