سفارش تبلیغ
صبا ویژن
دانش را بطلبید و آن را با بردباری و وقار زینت دهید و برای آن کس که به او دانش می آموزید ، فروتنی نمایید . [امام صادق علیه السلام]

علمی ،آموزشی،تحقیقاتی

Queue:کلاس صف    

 

 

صف :مجموعه ای از عناصر که ترتیب خروج به ترتیب ورود انجام می گیرد .این ساختار یک قسمت به نام ابتدا ویک قسمت به نام انتها دارد .عنصری که وارد می شود در انتها قرار می گیرد واگر بخواهیم عنصری را حذف کنیم از ابتدای صف حذف می کنیم .برای استفاده از این ساختار

تعریف می کنیم به صورت زیر:queueابتدا یک شی از نوع 

 

Queue    q =new    Queue()

                                                                                                                                                

         :Queue متدهای     

 

: از این متد برای وارد کردن عنصر به انتهای صف استفاده می شود.Enqueue

 ازاین متد برای حذف کردن عنصر از ابتدای صف بکار می رود.:Denqueue

از این متد برای نشان دادن اولین عنصر به کار می رود .:peek   

  از این متد برای نشان دادن تعداد عناصر به کار می رود .:count

 

 

          Array list  a =new Array list ()  :Array list

 

ساختاری است مشابه آرایه با این تفاوت که نسبت به آرایه حالت گویاتری دارد و مشکلاتی که استفاده از آرایه ها را به دنبال دارد دراین کلاس نداریم .به عنوان مثا ل اگر بخواهیم اندازه یک آرایه را تغییر دهیم مجبوریم که یک آرایه جدید ایجاد کنیم سپس عناصر را یک واحد به سمت ابتدا یا انتهای آرایه شیفت دهیم در حالی که این کلاس با اضافه شدن عنصر بزرگ وبا حذف عنصر حجم آن کم می شود.

 با استفاده از این متد می توان یک عنصر را به انتهای لیست اضافه کرد :Add

: با استفاده از این متد می توان یک عنصر را از انتهای لیست حذف کرد.Remove

: : با استفاده از این متدمی توان عنصر ولیست را به خانه چندم اضافه کرد. Insert

: : با استفاده از این متدمی توان ظرفیت یک عنصر را نشان داد . copysity

: : با استفاده از این متدمی توان عناصر را مرتب کرد . Sort

: : با استفاده از این متدمی توان عناصر را جستجو کرد . Binary serch




مژده فرجی ::: جمعه 87/9/8::: ساعت 5:28 عصر

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace WindowsApplication1

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click( sender, EventArgs e)

{

bmove(button2 );

}

private void bmove(Button b)

{

b.Text = "C#";

b.BackColor = Color.Coral;

b.Left = 100;

b.Top = 200;

b.Width = 200;

b.Height = 100;

}

private void button2_Click( sender, EventArgs e)

{

bmove(listBox1);

}

private void bmove(ListBox b)

{

b.Text = "C#";

b.BackColor = Color.Coral;

b.Left = 500;

b.Top = 200;

b.Width = 200;

b.Height = 100;

}

private void move1(Button c)

{

c.Left += 3;

}

private void timer1_Tick( sender, EventArgs e)

{

move1(button1);

}

private void button3_Click( sender, EventArgs e)

{

timer1.Start();

}

private void button4_Click( sender, EventArgs e)

{

timer1.Stop();

}

private void Form1_Load( sender, EventArgs e)

{

}

}

}




مژده فرجی ::: یکشنبه 87/9/3::: ساعت 1:20 عصر

using System;

using System.Collections.Generic;

using System.Text;

using System.Collections;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

Stack s = new Stack();

Console.WriteLine("Enter One Number:");

int a = Convert.ToInt16(Console.ReadLine());

while(a>0)

{

s.Push(a%2);

a = a / 2;

}

while (s.Count > 0)

Console.Write("{0}\t",s.Pop());

Console.ReadLine();

}

}

}




مژده فرجی ::: یکشنبه 87/9/3::: ساعت 1:18 عصر

using System;

using System.Collections.Generic;

using System.Text;

 

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

Random r = new Random();

char ch;

int a;

for (int k = 0; k < 20; k++)

{

for (int i = 0; i < 4; i++)

{

a = r.Next(65, 91);

ch = Convert.ToChar(a);

Console.Write("{0}", ch);

}

Console.WriteLine();

}

Console.ReadLine();

}

}

}




مژده فرجی ::: یکشنبه 87/9/3::: ساعت 1:18 عصر

using System;

using System.Collections.Generic;

using System.Text;

using System.Collections;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

ArrayList a = new ArrayList();

for (int i = 0; i < 10; i++)

a.Add(i);

a.RemoveAt(5);

Console.WriteLine("{0}",a[5]);

Console.ReadLine();

}

}

}




مژده فرجی ::: یکشنبه 87/9/3::: ساعت 1:17 عصر

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace WindowsApplication1

{

public partial class Form1 : Form

{

bool p = true;

byte mod;

double a, b, c;

public Form1()

{

InitializeComponent();

}

private void button1_Click( sender, EventArgs e)

{

if (p)

textBox1.Text += button1.Text;

else

{

textBox1.Clear();

textBox1.Text += button1.Text;

p = !p;

}

}

private void button16_Click( sender, EventArgs e)

{

a = Convert.ToDouble(textBox1.Text );

p = !p;

mod = 1;

}

private void button2_Click( sender, EventArgs e)

{

if (p)

textBox1.Text += button2.Text;

else

{

textBox1.Clear();

textBox1.Text += button2.Text;

p = !p;

}

}

private void button12_Click( sender, EventArgs e)

{

b = Convert.ToDouble(textBox1.Text);

switch (mod)

{

case 1:

c = a + b;

break;

case 2:

c = a - b;

break;

case 3:

c = a * b;

break;

case 4:

c = a / b;

break;

}

textBox1.Text = c.ToString();

}

private void button13_Click( sender, EventArgs e)

{

a = Convert.ToDouble(textBox1.Text);

p = !p;

mod = 2;

}

private void button15_Click( sender, EventArgs e)

{

a = Convert.ToDouble(textBox1.Text);

p = !p;

mod = 3;

}

private void button14_Click( sender, EventArgs e)

{

a = Convert.ToDouble(textBox1.Text);

p = !p;

mod = 4;

}

private void button3_Click( sender, EventArgs e)

{

if (p)

textBox1.Text += button3.Text;

else

{

textBox1.Clear();

textBox1.Text += button3.Text;

p = !p;

}

}

private void button4_Click( sender, EventArgs e)

{

if (p)

textBox1.Text += button4.Text;

else

{

textBox1.Clear();

textBox1.Text += button4.Text;

p = !p;

}

}

private void button5_Click( sender, EventArgs e)

{

if (p)

textBox1.Text += button5.Text;

else

{

textBox1.Clear();

textBox1.Text += button5.Text;

p = !p;

}

}

private void button6_Click( sender, EventArgs e)

{

if (p)

textBox1.Text += button6.Text;

else

{

textBox1.Clear();

textBox1.Text += button6.Text;

p = !p;

}

}

private void button7_Click( sender, EventArgs e)

{

if (p)

textBox1.Text += button7.Text;

else

{

textBox1.Clear();

textBox1.Text += button7.Text;

p = !p;

}

}

private void button8_Click( sender, EventArgs e)

{

if (p)

textBox1.Text += button8.Text;

else

{

textBox1.Clear();

textBox1.Text += button8.Text;

p = !p;

}

}

private void button9_Click( sender, EventArgs e)

{

if (p)

textBox1.Text += button9.Text;

else

{

textBox1.Clear();

textBox1.Text += button9.Text;

p = !p;

}

}

private void button10_Click( sender, EventArgs e)

{

if (p)

textBox1.Text += button10.Text;

else

{

textBox1.Clear();

textBox1.Text += button10.Text;

p = !p;

}

}

private void button17_Click( sender, EventArgs e)

{

a = Convert.ToDouble(textBox1.Text );

a = Math.Sin(a);

textBox1.Text = a.ToString();

}

private void Form1_Load( sender, EventArgs e)

{

}

}

}




مژده فرجی ::: یکشنبه 87/9/3::: ساعت 1:16 عصر

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

int r;

Console.WriteLine("Enter Two Number");

int a=int.Parse(Console.ReadLine());

int b=Convert.ToInt16(Console.ReadLine());

while (a%b > 0)

{

r = a % b;

a = b;

b = r;

}

Console.WriteLine("{0}",b);

Console.ReadLine();

}

}

}




مژده فرجی ::: یکشنبه 87/9/3::: ساعت 1:14 عصر

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

int[] a=new int[5];

for (int i = 0; i < 5; i++)

a[i] = Convert.ToInt16(Console.ReadLine());

for(int k=4;k>0;k--)

for(int j=0;j<k;j++)

if (a[j] > a[j + 1])

{

int temp = a[j];

a[j] = a[j + 1];

a[j + 1] = temp;

}

for (int i = 0; i < 5; i++)

Console.Write("{0}\t", a[i]);

Console.ReadLine();

}

}

}




مژده فرجی ::: یکشنبه 87/9/3::: ساعت 1:13 عصر

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Class1

{

public double r;

public Class1(int a)

{

r = a;

}

public double area()

{

return r * r * 3.14;

}

}

/********************************************************************************************/

class Program

{

static void Main(string[] args)

{

Class1 d = new Class1(1);

Console.WriteLine("{0}\n{1}",d.area(),Program.p(d));

Console.ReadLine();

}

static double p(Class1 c)

{

return (c.r) * 2 * 3.14;

}

}

}




مژده فرجی ::: یکشنبه 87/9/3::: ساعت 1:12 عصر

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{ int a, b,c;

Console.Write("Enter Three Number:");

a = Convert.ToInt16(Console.ReadLine());

b = Convert.ToInt16(Console.ReadLine());

c = Convert.ToInt16(Console.ReadLine());

int max = a;

if (b > max)

max = b;

else if (c > max)

max = c;

Console.WriteLine("Max={0}",max.ToString() );

Console.ReadLine();

}

}

}




مژده فرجی ::: یکشنبه 87/9/3::: ساعت 1:11 عصر

<   <<   6   7   8   9      >
>> بازدیدهای وبلاگ <<
بازدید امروز: 1


بازدید دیروز: 7


کل بازدید :59443
 
 >>اوقات شرعی <<
 
>> درباره خودم<<
مدیر وبلاگ : مژده فرجی[85]
نویسندگان وبلاگ :
سمانه طالبی (@)[0]

مژده فرجی (@)[0]


 
 
>>موسیقی وبلاگ<<
 
>>اشتراک در خبرنامه<<
 
 
>>طراح قالب<<