Typing Games 1

Source: Internet
Author: User

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

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.