zoukankan      html  css  js  c++  java
  • 第三节 3练习1 简单

    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 _3练习1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                string str_width = tb_width.Text;
                string str_height = tb_height.Text;
                //判断值是否有效
                int i1, i2, sum;
                if (!int.TryParse(str_width, out i1)) {
                    MessageBox.Show("宽为非整数!");
                    return;
                }
                if (!int.TryParse(str_height, out i2)) {
                    MessageBox.Show("高为非整数!");
                    return;
                }
                sum = i1 * i2;
                tb_sum.Text = Convert.ToString(sum);
    
    
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                string email = tb_email.Text;
                //进行字符串进行分析,然后放入数组中的
                //这里用数组的长度来判断该email是否有效
                string[] str = email.Split('@');
                if (str.Length != 2) {
                    MessageBox.Show("Email不合法!");
                    return;
                }
    
                tb_name.Text = str[0];
                tb_www.Text = str[1]; 
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                //求累加
                string str1 = tb_start.Text;
                string str2 = tb_end.Text;
                int i1, i2;
                if (!int.TryParse(str1, out i1)){
                    MessageBox.Show("第一个数值不是整数!");
                    return;
                }
                if (!int.TryParse(str2, out i2)) {
                    MessageBox.Show("第二个数值不是整数!");
                    return;
                }
                if (i2 <= i1) {
                    MessageBox.Show("第二个值不能小大第一个值!");
                    return;
                }
                int sum = 0;
                for (int i = i1; i <= i2; i++) {
                    sum += i;
                }
                tb_count.Text = Convert.ToString(sum);
            }
    
    
        }
    }
    

      

  • 相关阅读:
    【luogu P1343 地震逃生】 题解
    【luogu P3931 SAC E#1
    【luogu P3275 [SCOI2011]糖果】 题解
    【luogu P2947 [USACO09MAR]向右看齐Look Up】 题解
    【luogu P1456 Monkey King】 题解
    【luogu P3377 左偏树(可并堆)】 模板
    【luogu P1993 小K的农场】 题解
    Sqlmap注入Base64编码的注入点
    kali高速更新源以及主题修改方法
    DiscuzX3.1搬家全过程
  • 原文地址:https://www.cnblogs.com/xiangxiaodong/p/2370605.html
Copyright © 2011-2022 走看看