Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- static int[] c = new int[5];
- public Form1()
- {
- InitializeComponent();
- random();
- }
- private double atlag()
- {
- double tmp=0;
- for (int i = 0; i < c.Length; i++)
- {
- tmp += c[i];
- }
- return tmp/5;
- }
- private void random()
- {
- Random r = new Random();
- for (int i = 0; i < c.Length; i++)
- {
- c[i] = r.Next(10, 100);
- }
- string a = "";
- for (int i = 0; i < c.Length; i++)
- {
- a = a + c[i].ToString() + " ";
- }
- label1.Text = a;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- random();
- }
- private void atlagos()
- {
- double f = atlag();
- if (f <= 50)
- {
- label2.ForeColor = Color.Green;
- }
- else
- {
- label2.ForeColor = Color.Red;
- }
- label2.Text = Convert.ToString(f);
- }
- private void button2_Click(object sender, EventArgs e)
- {
- atlagos();
- }
- }
- }
Add Comment
Please, Sign In to add comment