[C#] Generate random matris and sum diagonal's
Hi my friends today i make some friends homework its basic C# application. You can find source code and program below...Download
/*
*Code Start
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Matris
{
public partial class Form1 : Form
{
//Coded By Kacak41
//http://www.pcply.org
//03.01.2014
int[,] array = new int[5, 5];
Random rnd1 = new Random();
int sum = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
array[i, j] = rnd1.Next(10);
richTextBox1.Text += " "+ array[i, j] ;
}
richTextBox1.Text += "\n";
}
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
if (i == j)
{
sum += array[i, j];
}
else if (i + j == 4)
{
sum += array[i, j];
}
}
richTextBox1.Text += "\n";
}
label1.Text = "Sum:" + sum;
}
}
}
/*
*Code End
*/
*Code End
*/
0 comments: