Advertisement
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;
- using System.IO;
- namespace _444
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- }
- int stud_count, subj_count;
- int[,] mark;
- string[] stud = { "Путен", "KillREAL", "Зиленский", "Трамп", "Миркель", "Ким" };
- string[] sudj = { "Православие", "УПД", "ОБЖ", "ИЗО" };
- private void button1_Click(object sender, EventArgs e)
- {
- stud_count = (int)numericUpDown1.Value;
- subj_count = (int)numericUpDown2.Value;
- dataGridView1.RowCount = stud_count + 1;
- dataGridView1.ColumnCount = subj_count + 1;
- mark = new int[stud_count, subj_count];
- Random rnd = new Random();
- for (int i = 0; i < stud_count; i++)
- {
- for (int j = 0; j < subj_count; j++)
- {
- mark[i, j] = rnd.Next(2, 6);
- }
- for (int j = 0; j < subj_count; j++)
- {
- dataGridView1.Rows[0].Cells[j + 1].Value = sudj[j];
- }
- }
- for (int i = 0; i < stud_count; i++)
- {
- dataGridView1.Rows[i + 1].Cells[0].Value = stud[i];
- for (int j = 0; j < subj_count; j++)
- {
- dataGridView1.Rows[i + 1].Cells[j + 1].Value = mark[i, j];
- }
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- int a = 0, b = 0;
- for (int i = 0; i < stud_count; i++)
- {
- for (int j = 0; j < subj_count; j++)
- {
- if (mark[i, j] == 4)
- a++;
- else if (mark[i, j] == 3)
- b++;
- }
- }
- if (a == b)
- textBox1.Text = "Кол-во хороших и удовлетворительных оценок одинаково\r\n";
- else if (a > b)
- textBox1.Text = "Кол-во хороших оценок преобладает\r\n";
- else if (a < b)
- textBox1.Text = "Кол-во удовлетворительных оценок преобрадает\r\n";
- }
- private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- mark[e.RowIndex - 1, e.ColumnIndex - 1] = int.Parse(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
- }
- catch
- {
- MessageBox.Show("Плюха");
- dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = mark[e.RowIndex - 1, e.ColumnIndex - 1];
- }
- }
- private void Button3_Click(object sender, EventArgs e)
- {
- int c = 0;
- for (int i = 0; i < stud_count; i++)
- {
- bool f = true;
- for (int j = 0; j < subj_count; j++)
- {
- if (mark[i, j] <= 3)
- {
- f = false;
- break;
- }
- }
- if (f)
- c++;
- }
- textBox1.Text = c + " студентов сдало на стипендию\r\n";
- }
- private void Button5_Click(object sender, EventArgs e)
- {
- textBox1.Clear();
- int c = 0;
- for (int i = 0; i < stud_count; i++)
- {
- c = 0;
- textBox1.Text += "У " + stud[i] + " ";
- for (int j = 0; j < subj_count; j++)
- {
- if (mark[i, j] == 3)
- c++;
- }
- if (c > 0)
- textBox1.Text += c + " удовлетворительных оценок\r\n";
- else
- textBox1.Text += " нет удовлетворительных оценок\r\n";
- }
- }
- private void Button4_Click(object sender, EventArgs e)
- {
- textBox1.Clear();
- for (int i = 0; i < subj_count; i++)
- {
- int a = 0, b = 0, c = 0;
- for (int j = 0; j < stud_count; j++)
- {
- if (mark[j, i] == 5)
- a++;
- else if (mark[j, i] == 4)
- b++;
- else if (mark[j, i] == 3)
- c++;
- }
- if (a > b && a > c)
- textBox1.Text += "По " + sudj[i] + " больше отличных оценок\r\n";
- else if (b > a && b > c)
- textBox1.Text += "По " + sudj[i] + " больше хороших оценок\r\n";
- else if (c > a && c > b)
- textBox1.Text += "По " + sudj[i] + " больше удовлетворительных оценок\r\n";
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement