zoukankan      html  css  js  c++  java
  • 计算

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    
    namespace 计算
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
           
           
       
               public static int count = 0;
               public static int right = 0;
               int a, b;
    
            private void button2_Click(object sender, EventArgs e)
            {
    
                an();
               
    
            }
         
                
    
            private void button3_Click(object sender, EventArgs e)
            {
                
                string z = textBox3.Text;
                string s = textBox4.Text;
    
                int q = int.Parse(s);
                if (z == "+")
                {
    
                    if (q == a + b)
                    {
                        right++;
    
    
    
                    }
                    count++;
    
                }
                if (z == "-")
                {
    
                    if (q == a - b)
                    {
                        right++;
    
                    }
                    count++;
    
                }
                if (z == "*")
                {
    
                    if (q == a * b)
                    {
                        right++;
    
                    }
                    count++;
    
                }
                if (z == "/")
                {
    
                    if (q == a / b)
                    {
                        right++;
    
                    }
                    count++;
    
                }
            
            an();
            } 
            private void an()
            {
                Random shu=new Random();
                
                a=shu.Next(1,11);
                b=shu.Next(1,11);
                textBox1.Text = a.ToString();
                textBox2.Text = b.ToString();
                textBox3.Text = "";
                textBox4.Text = "";
                
            }
    
            private void button1_Click_1(object sender, EventArgs e)
            {
                Form2 da = new Form2();
                da.ShowDialog();
            }
            
        }
    }
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace 计算
    {
        public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }
    
            private void Form2_Load(object sender, EventArgs e)
            {
                textBox1.Text = Form1.count.ToString();
                textBox2.Text = Form1.right.ToString();
            }
    
           
        
        }
    }

    总结:

    这次写这代码,感觉自己对这掌握这方面的知识还是太少。

    自己预计两个小时完成 结果用了三个多小时才完成,自己应该多去掌握这方面知识以此来缩短编写的时间,并且也不会在编写时出现那么多错误,自己以后多学习这方面知识。

  • 相关阅读:
    Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level
    Python3 运算符
    Python3 注释
    Python3 解释器
    Python3 环境搭建
    Python 3 教程
    Python3 基本数据类型
    趣闻|Python之禅(The Zen of Python)
    ios开发笔记根据传入字符串的长度动态生成label,并按照屏幕宽度排列
    iOS开发设置tableview的分割线
  • 原文地址:https://www.cnblogs.com/fanxiaotian/p/4856477.html
Copyright © 2011-2022 走看看