classProgram { Public voidDayin () {Console.WriteLine ("Hollo World"); } /// <summary> ///Accumulate sum/// </summary> /// <param name= "n" ></param> /// <returns></returns> Public intLeijia (intN) {intsum =0; for(inti =1; I <= n;i++) {sum+=i; } returnsum; } /// <summary> ///Enter a number to determine if it is prime/// </summary> /// <param name= "n" ></param> /// <returns></returns> Public voidZhishu (intN) {intCount =0; for(inti =1; I <= n;i++ ) { if(n%i==0) {Count++; } } if(Count = =2) {Console.WriteLine ("Prime Number"); } Else{Console.WriteLine ("not prime ."); } } /// <summary> ///to find the factorial and its/// </summary> /// <param name= "n" ></param> /// <returns></returns> Public voidJiecheng (intN) {intJiecheng =1; inthe =0; for(inti =1; I <=n; i++) {Jiecheng*=i; He= he +Jiecheng; } Console.WriteLine ("Factorial is"+jiecheng+"Factorial and yes"+He); } /// <summary> ///scissors three innings and two wins/// </summary> /// <param name= "a" ></param> /// <param name= "B" ></param> Public voidCaiquan () {intRenying =0; intDiannaoying =0; for(inti =1; I <=3; i++) {Console.Write ("Please input people punch (0-scissors, 1-stone, 2-cloth) a="); intA =int. Parse (Console.ReadLine ()); Random R=NewRandom (); intb = R.next (3); Console.WriteLine ("Computer Punch (0-scissors, 1-stone, 2-cloth) b="+b); if(A-B =1|| A-B =-2) {renying++; Console.WriteLine ("people win a game"); } Else if(A = =b) {Console.WriteLine ("Draw"); I--; Continue; } Else{diannaoying++; Console.WriteLine ("Computer wins a game"); } if(Renying >=2) {Console.WriteLine ("three innings, two wins."); Break; } Else if(Diannaoying >=2) {Console.WriteLine ("three innings, two wins, computer wins ."); Break; } } } //Main function Static voidMain (string[] args) { while(true) { NewProgram (). Dayin (); Console.WriteLine ("Please enter a positive integer"); intn =int. Parse (Console.ReadLine ()); intJieguo =NewProgram (). Leijia (n); Console.WriteLine (Jieguo); NewProgram (). Zhishu (n); NewProgram (). Jiecheng (n); NewProgram (). Caiquan (); Console.ReadLine (); } } }
function and its invocation