You are on page 1of 2

using using using using using using using using

System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace grafuri { public partial class Form1 : Form { private TextBox[,] tb = new TextBox[20, 20]; private Button[] b = new Button[20]; private int[] x = new int[20]; private int[] y = new int[20]; private int[] viz = new int[20]; private int[,] a = new int[20, 20]; //static Stack <Int32> S = new Stack<Int32>(); //static Queue <Int32> C = new Queue<Int32>(); int n; //,vizitate; // private System.Windows.Forms.Timer timer1, timer2; //timer1.Tick +=new EventHandler(timer1_Tick); //timer.start public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void Deseneaza_noduri_Click(object sender, EventArgs e) { int i,j; n = Int32.Parse(textBox1.Text); for(i=1;i<=n;i++) for(j=1;j<=n;j++) { tb[i, j] = new TextBox(); tb[i, j].Width = 20; tb[i, j].Left = j * 20; tb[i, j].Top = 150+ i * 20; tb[i, j].BackColor = Color.Yellow; tb[i, j].Font = new Font("Microsoft Sans Serif", 11); this.Controls.Add(tb[i, j]); } for (i=1;i<=n;i++){ b[i]=new Button(); b[i].Height = 20; b[i].Top = Convert.ToInt32(300 + 100 *Math.Sin(i * 2 * Math.PI / n)); b[i].Left = Convert.ToInt32(350 + 100 * Math.Cos(i * 2 * Math.PI / n)); b[i].BackColor = Color.Yellow; b[i].Text = "" + i;

y[i] = b[i].Top; x[i] = b[i].Left; viz[i] = 0; this.Controls.Add(b[i]); } } private void Deseneaza_muchii_Click(object sender, EventArgs e) { int i,j; bool ok = true; for(i=1; i<=n; i++) for(j=1;j<=n; j++) { if(tb[i,j].Text == "0") a[i,j] = 0; else a[i, j] = 1; } for(i=1;i<=n;i++){ for(j=1;j<=n;j++) if(a[i,j] != a[j, i]) ok = false; if(a[i, i] != 0) ok = false; } if(ok) { Graphics g = this.CreateGraphics(); Pen p = new Pen(Color.BlueViolet); p.Width = 3; for(i=1; i<=n; i++) for(j=1; j<=n; j++) if(a[i, j] == 1) g.DrawLine(p, x[i] +5, y[i] + 5, x[j] + 5, y[j] + 5) ; } else MessageBox.Show("Matricea nu este data corect!"); } } }