登录 注册

C# 101102

收藏
[C#] 标签: 2013-10-12 13:26
原始代码 全屏查看 0评 / 0藏 / 7146阅  跳至 / 75行
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace test1
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public int num = 1;
        public double[] arr = new double[20];
        public int element;


        public MainWindow()
        {
            InitializeComponent();
            textBox1.Text = "1";
        }

        private void button1_输入成绩_Click(object sender, RoutedEventArgs e)
        {
            element = 0;
            arr[element] = Convert.ToDouble(textBox2.Text);
            element++; num++;
            textBox1.Text = Convert.ToString(num);
            textBox2.Text = "";


        }



        private void button2_平均分_Click(object sender, RoutedEventArgs e)
        {
            double s = 0;
            for (int i = 0; i < num - 1; i++)
                s += arr[i];
            textBox3.Text = Convert.ToString(s / (num - 1));
        }

       

        private void button4_最低分_Click(object sender, RoutedEventArgs e)
        {
            double low = 0;
            for (int i = 0; i < num - 1; i++)
                low = (arr[i] < low) ? arr[i] : low;
            textBox5_low.Text = Convert.ToString(low);

        }

        private void button3_最高分_Click(object sender, RoutedEventArgs e)
        {
            double top = 0;
            for (int i = 0; i < num - 1; i++)
                top = (arr[i] > top) ? arr[i] : top;
            textBox4_top.Text = Convert.ToString(top);
 
        }

    }
}

最新评论

  · · · · · ·  (共0条)

目前还没有评论

登录后您才可以发表评论。 马上登录 立即注册
hpx
2013-04-22加入
Back to Top