Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button4_Click(object sender, EventArgs e)
- {
- int[] notas = new int[12];
- for (int i = 0; i < 12; i++)
- {
- notas[i] = Convert.ToInt32(formandos[i, 1]);
- }
- label3.Text= label3.Text + Convert.ToString(GetMax(notas));
- label4.Text = label4.Text + Convert.ToString(GetMin(notas));
- label5.Text = label5.Text + Convert.ToString(GetAvg(notas));
- }
- public static int GetMax(int[] intCollection)
- {
- int max = int.MinValue;
- foreach (int i in intCollection)
- {
- if (i > max)
- {
- max = i;
- }
- }
- return max;
- }
- public static int GetMin(int[] intCollection)
- {
- int min = intCollection[0];
- foreach (int i in intCollection)
- {
- if (i < min)
- {
- min = i;
- }
- }
- return min;
- }
- public static int GetAvg(int[] intCollection)
- {
- int avg = 0;
- foreach (int i in intCollection)
- {
- avg += i;
- }
- return avg/intCollection.Length;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement