namespacejisuanqi{ Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); } Public Static intCount =0; Public Static intright =0; Private voidRandomnum () {Random rad=NewRandom (); intm1,m2; M1= Rad. Next (1,101); M2= Rad. Next (1,101); TextBox1. Text=M1. ToString (); TextBox2. Text=m2. ToString (); TextBox3. Text=""; Count++; } Private voidJisuan () {Random js=NewRandom (); intA, B; A= js. Next ( One); b= js. Next ( One); TextBox1.Text=a.tostring (); TextBox2.Text=b.tostring (); Count++; } Private voidTextbox4_keydown (Objectsender, KeyEventArgs e) { stringFuhao; Fuhao=Textbox4.text; if(Fuhao = ="+") {Lable1. Text="+"; } Else if(Fuhao = ="-") {Lable1. Text="-"; } Else if(Fuhao = ="*") {Lable1. Text="*"; } Else{label0. Text="/"; } } Private voidButton1_Click (Objectsender, EventArgs e) {Jisuan (); } Private voidTextbox3_keydown (ObjectSender,eventargs e) { intTxt3; if(Textbox4.text = ="+") {Txt3=int. Parse (TextBox1.Text) +int. Parse (TextBox2. Text); } Else if(Textbox4.text = ="-") {Txt3=int. Parse (TextBox1.Text)-int. Parse (TextBox2. Text); } Else if(Textbox4.text = ="*") {Txt3=int. Parse (TextBox1.Text) *int. Parse (TextBox2. Text); } Else{txt3=int. Parse (TextBox1.Text)/int. Parse (TextBox2. Text); } if(E.keycode = =Keys. Enter) {if(TextBox3. Text = =Txt3. ToString ()) { Right++; TextBox3. Text=""; Jisuan (); } } } } }}namespacejisuanqi{ Public Partial classForm2:form { PublicForm2 () {InitializeComponent (); } Private voidButton2_Click (Objectsender, EventArgs e) {textbox3.enabled=false; NewForm2 (). ShowDialog (); } Public Partial classForm2:form { PublicForm2 () {InitializeComponent (); } Private voidForm2_load (Objectsender, EventArgs e) {TextBox1.Text=Form1.Count.ToString (); TextBox2.Text= (((form1.right)/(Double) (Form1.count)) * -). ToString () +"%"; } } }
Operation Result:
Summarize:
I do the form program, I think the form program is relatively simple, the console program does not know where to start. I do this program more time-consuming, with 5 hours, before the C # class, practice the addition training, I thought it would be very simple and quick to do it, but in the time of doing a lot of tests to succeed, so, I think I usually practice not enough, so I will add practice later.
Arithmetic of integers