Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Using System.Collections;
Namespace Essays
{
Class Program
{
<summary>
Compares two strings with the same number of elements
</summary>
<param name= "a" ></param>
<param name= "B" ></param>
<param name= "n" ></param>
<returns></returns>
public int avg (string A, string b, int n)
{
int count = 0;
for (int i = 0; i < n; i++)
{
if (a.substring (I, 1). ToLower () = = B.substring (i, 1). ToLower ())
{
Count + = 1;
}
}
return count;
}
static void Main (string[] args)
{
Typing test
Random occurrences of several A-Z characters are case insensitive
Typing from the keyboard matches the above characters, calculating the input time and the correct rate
Console.WriteLine ("Please enter the number of characters you need to test:");
int n = Int. Parse (Console.ReadLine ());
Random ran = new random ();
ArrayList ss = new ArrayList ();
Ss. ADD ("A"); Ss. ADD ("B"); Ss. ADD ("C"); Ss. ADD ("D"); Ss. ADD ("E"); Ss. ADD ("F");
Ss. ADD ("G"); Ss. ADD ("H"); Ss. ADD ("I"); Ss. ADD ("J"); Ss. ADD ("K"); Ss. ADD ("L");
Ss. ADD ("M"); Ss. ADD ("N"); Ss. ADD ("O"); Ss. ADD ("P"); Ss. ADD ("Q"); Ss. ADD ("R");
Ss. ADD ("S"); Ss. ADD ("T"); Ss. ADD ("U"); Ss. ADD ("V"); Ss. ADD ("W"); Ss. ADD ("X");
Ss. ADD ("Y"); Ss. ADD ("Z");
string s = "";
for (int i = 0; i < n; i++)
{
s+= Ss[ran. Next (26)]. ToString ();
}
Console.WriteLine ("The game starts (press the prompt to enter characters:");
Console.WriteLine (s);
DateTime dt = DateTime.Now;
string S1 = "";
for (int i = 0; i < n; i++)
{
S1 + = Console.read ();
}
Console.ReadLine ();
DateTime dt1 = DateTime.Now;
Program Hanshu=new program ();
Int J = Hanshu.avg (S,s1,n);
Double A = (double) j/n;
Console.Write ("Your input time is: {0} seconds", Math.ceiling (DT1-DT). TotalSeconds));
Console.WriteLine ("Your input accuracy rate is: {0}", a);
Console.ReadLine ();
}
}
}
Typing Games 1