The requirement of this operation is to make the arithmetic of the last job further improved, not in the subtraction of negative numbers, can not appear in addition to the situation.
Like this, we don't know how to specify a value that must be a positive integer, so we do it in the stupidest way, defining an F whose value is a multiple of e,d.
and d as a divisor, f as dividend, so anyway F is the e-times of D, and we define the range of E is also a positive integer between (1,10), so no matter how random, F is a positive integer multiples of D, there will be no surplus number of cases.
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading;
Namespace ConsoleApplication3
{
Class Program
{
static void Main (string[] args)
{
BOOL BK = FALSE;
New Thread (() =
{
int DJs = 10;
DateTime lt = DateTime.Now; DT = Datetime
Do
{
if ((DATETIME.NOW-LT). TotalSeconds >= 1)
{
lt = DateTime.Now;
djs--;
Console.WriteLine (DJs);
}
Thread.Sleep (100);
} while (DJs > 0 &&!bk);
Console.WriteLine ("Time is up, stop answering");
}). Start ();
Console.ReadLine ();
BK = true;
}
}
}
Requirements to achieve the countdown we also consider, we also through a variety of channels to achieve, finally although done, but not very ideal, so there is no plug into the code inside. The key is still do not know where to plug in, I hope the teacher can give a suggestion after reading for us to relieve confusion.
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace subtraction Operations
{
Class Program
{
static void Main (string[] args)
{/* program runs, output 1234 key selection algorithm.
After the completion of the calculation prompts the wrong, Random press "1-9 key" and then press "space" to restart the next calculation
If all the calculation is complete, after the prompt right and wrong directly press "enter" to display the correct number of questions. */
int correct = 0;
int error = 0;
Do
{
Console.WriteLine ("Input 1 for addition operation, input 2 for subtraction operation, input 3 for multiplication, input 4 for division operation");
Random num = new random ();
int a = num. Next (0, 11);
int b = num. Next (0, 11);
int c = num. Next (0, a + 1);//can try random number C not greater than random number a
int d = num. Next (1, 10);//to divide the divisor range by 0, and the divisor is within 10.
int e = num. Next (1, 10);//Specify the value of a quotient, not 0, and within 10.
int f = e * d;//is divisor = divisor * Quotient, can make dividend must be the divisor of the whole 10 times times.
String A = Console.ReadLine ();
Switch (A)
{
Case "1":
Console.WriteLine ("{0}+{1}=? Please enter the answer ", A, b);
int a plus b = Convert.ToInt32 (Console.ReadLine ());
if (a plus b = = a + b)
{
Console.WriteLine ("You are right!");
correct + +;
}else
{
Console.WriteLine ("You Are wrong!");
Error + +;
}break;
Case "2":
Console.WriteLine ("{0}-{1}=? Please enter the answer, ", A, c);
int a minus c = Convert.ToInt32 (Console.ReadLine ());
if (a minus c = = a-c)
{
Console.WriteLine ("You are right!");
correct + +;
}
Else
{
Console.WriteLine ("You Are wrong!");
Error + +;
}break;
Case "3":
Console.WriteLine ("{0}*{1}=? Please enter the answer, ", A, b);
int a by B = Convert.ToInt32 (Console.ReadLine ());
If (A by b = = A * b)
{
Console.WriteLine ("You are right!");
correct + +;
}
Else
{
Console.WriteLine ("You Are wrong!");
Error + +;
}break;
Case "4":
Console.WriteLine ("{0}/{1}=? Please enter the answer, ", f,d);
int f except d = Convert.ToInt32 (Console.ReadLine ());
if (f except D ==f/d)
{
Console.WriteLine ("You are right!");
correct + +;
}
Else
{
Console.WriteLine ("You Are wrong!");
Error + +;
}break;
}
}
while (Console.ReadLine ()! = "");
Console.WriteLine ("You have answered {0} questions correctly: {1}, Error: {2}", correct + error, correct, error);
Console.ReadLine ();
}
}
}
This is the source code of our homework, I hope the teacher can give some advice.
Summary: In fact, trooped programming is also a very good suggestion, high efficiency. And in the face of problems, two people are thinking, think more than a person, and combined with two people's thinking results, often have unexpected results. Thus the idea of one plus one greater than two is realized. On the whole, pairing writing is really good.
Further improvement of the third operation---arithmetic