using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace newgraf
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int[,] q = new int[2,2];
q[0, 0] = 0;
q[0, 1] = 1;
q[1, 0] = 1;
q[1, 1] = 0;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
if (q[i, j] == 0)
textBox1.Text = "NULL";
using System.Linq;
else textBox1.Text = "NOT NULL";
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
if (i!=j && q[i,j]==1)
if(q[i,i]==0)
textBox1.Text = "Complete";
else textBox1.Text = "not Complete";
}
}
}
==============================================================
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 Equeue
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int []q =new int [5] ;
q[0] = 1;
q[1] = 2;
q[2] = 3;
int f = 0, r = 2,size = 5, item = 9;
for (int i = f; i < q.Length; i++)
textBox1.Text += Convert.ToString(q[i]);
if (r >= size)
textBox1.Text = "Overflow";
else
{
r=r+1;
q[r] = item;
}
for (int i = f; i < q.Length; i++)
textBox2.Text += Convert.ToString(q[i]);
}
private void button2_Click(object sender, EventArgs e)
{
int[] q = new int[5];
q[0] = 1;
q[1] = 2;
q[2] = 3;
int f = 0;
textBox3.Text = "";
for (int i = 0; i < q.Length; i++)
textBox3.Text += Convert.ToString(q[i]);
if (f <= -1)
textBox3.Text = "Underflow";
else
{
q[f] = 0;
f--;
}
for (int i = 0; i < q.Length; i++)
textBox4.Text += Convert.ToString(q[i]);
}
private void button3_Click(object sender, EventArgs e)
{
int[,] q = new int[2,2];
q[0, 0] = 0;
q[0, 1] = 0;
q[1, 0] = 0;
q[1, 1] = 1;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
if (q[i,j] == 0)
textBox4.Text = "null";
textBox4.Text = "not null";
}
}
}
==============================================================
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 push_pop
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//PUSH
int[] s = new int[5];
s[0] = 1;
s[1] = 2;
s[2] = 3;
int top = 2, size = 5, item = 9;
for (int i = 0; i <=top; i++)
textBox1.Text += Convert.ToString(s[i]);
if (top >= size)
textBox1.Text = "Overflow";
else
{
top++;
s[top] = item;
}
for (int i = 0; i <= top; i++)
textBox2.Text += Convert.ToString(s[i]);
}
private void button2_Click_1(object sender, EventArgs e)
{
// POP
int[] s = new int[5];
s[0] = 1;
s[1] = 2;
s[2] = 3;
int top = 2;
for (int i = 0; i <= top; i++)
textBox1.Text += Convert.ToString(s[i]);
if (top <= -1)
textBox1.Text = "UnderFlow";
else
{
s[top] = 0;
top--;
}
for (int i = 0; i <= top; i++)
textBox2.Text += Convert.ToString(s[i]);
}
private void button3_Click(object sender, EventArgs e)
{
//program to push five items into stack
int[] s = new int[5];
int top = -1, size = 5, item = 1;
for (int i = 0; i < size; i++)
{
if (top >= size)
textBox1.Text = "Overflow";
else
{
top++;
s[top] = item;
item++;
}
}
for (int i = 0; i <= top; i++)
{
Array.Reverse(s);
textBox2.Text += Convert.ToString(s[i]);
}
}
private void button4_Click_1(object sender, EventArgs e)
{
// print into reverse order
int[] s = { 1, 2, 3, 4, 5 };
int[] q = new int[5];
int top = 5, size = 5;
int f = 0, r = -1;
for (int i = 0; i < size; i++)
{
textBox1.Text += Convert.ToString(s[i]);
if (top <= -1)
textBox1.Text = "UnderFlow";
else
{
if (r >= size)
textBox1.Text = "Overflow";
else
{
r++;
q[r] = s[top - 1];
top--;
}
}
}
for (int i = 0; i < size; i++)
textBox2.Text += Convert.ToString(q[i]);
}
private void button5_Click(object sender, EventArgs e)
{
}
}
}
==============================================================
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 WindowsFormsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int i=0, counter = 0,size=10;
// char[] s = new char [size];
string s="";
s=textBox1.Text;
for (i = 0; i<s.Length ; i++)
if (s[i] =='(')
counter++;
else
if (s[i] ==')' )
counter--;
if (counter == 0)
textBox2.Text="Accept";
else textBox2.Text = "Not accept";
}
}
}
==============================================================
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 cque
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int[] q = new int[5];
q[0] = 0;
q[1] = 0;
q[2] = 1;
q[3] = 2;
q[4] = 3;
int f = 2, r = 4, size = 5, item = 9;
for (int i = 0; i <= r; i++)
textBox1.Text += Convert.ToString(q[i]);
if (r >= size-1)
r = 0;
else
r = r + 1;
if (f == r)
textBox1.Text = "Overflow";
else
q[r] = item;
if (r < f)
q[0] =q[r];
Array.Reverse(q);
for (int i = 0; i < q.Length; i++)
textBox2.Text += Convert.ToString(q[i]);
textBox3.Text = Convert.ToString(f);
textBox4.Text = Convert.ToString(r);
}
}
}