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

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

using System;

using System.Collections.Generic;

using System.Text;

using System.Collections;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

Queue q = new Queue();

int n;

do

{ n = int.Parse(Console.ReadLine());

q.Enqueue(n);

} while (n != 0);

int sum = 0;

while (q.Count != 2)

{

int a = Convert.ToInt16(q.Dequeue());

sum += Math.Abs(a-Convert.ToInt16(q.Peek()));

}

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

Console.ReadLine();

}

}

}




مژده فرجی ::: پنج شنبه 87/8/30::: ساعت 12:25 عصر

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.Write("Enter One Number");

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

while (n > 0)

{

int r = n % 16;

if (r <= 9)

s.Push(r.ToString());

else {

switch (r)

{

case 10:

s.Push("A");

break;

case 11:

s.Push("B");

break;

case 12:

s.Push("C");

break;

case 13:

s.Push("D");

break;

case 14:

s.Push("E");

break;

case 15:

s.Push("F");;

break;

}

}

n = n / 16;

}

while (s.Count > 0)

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

Console.ReadLine();

}

}

}




مژده فرجی ::: پنج شنبه 87/8/30::: ساعت 12:23 عصر

اجزای زبان سی شارپ کلاس است که کلاس ها شامل اشیا یا متدها است
دستور using: برای اعلام دستور یا معرفی فضاهای نامی منظور 3خط اول سی شارپ
ذستور console: برای متغیر های رشته ای استفاده می شود وبردن اطلاعات به خروجی
دستور readline:برای خواندن دستورات استفاده می شود وبا کلید اف پنج می توان خروجی را دید
دستورwriteline:برای نوشتن دستورات به کار می رود ودر آن خروجی دیده نمی شود
دستور convert:برای دریافت عدد در برنامه می نویسیم
                                                                                                                                                                                              ساختار کنترلی در سی شارپ  


در حالت معمولی برنامه ایی که می نویسیم از خط اول شروع و خط به خط اجرا می شود تا به انته برسد برای دستوراتی از یک برنامه چند بار اجرا می شود و یا اجرا می شود ویا اینکه تحت شرایطی
دستوری اجرا نگردد از ساختاری به نام ساختار کنترلی استفاده می کنیم که به دو دسته تقسیم می شود
if   if else  if elseif else switch case                                                ساختار تصمیم : از جمله
for  while  dowhile  foreach                                                                 ساختار تکرار : از جمله

 




مژده فرجی ::: پنج شنبه 87/8/30::: ساعت 12:20 عصر

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

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

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

bool p = true ;

for (int i = 2; (i <= (n / 2))&&p ; i++)

{

if (n % i == 0)

p = false ;

}

if (!p)

Console.WriteLine("Morakab");

else

Console.WriteLine("Aval");

Console.ReadLine();

}

}

}

سمانه طالبی




مژده فرجی ::: سه شنبه 87/8/28::: ساعت 9:41 صبح

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

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

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

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

int r;

while ((r = a % b) != 0)

{

a = b;

b = r;

}

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

Console.ReadLine();

 

}

}

}

سمانه طالبی




مژده فرجی ::: سه شنبه 87/8/28::: ساعت 9:32 صبح

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

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

string s = " ";

switch (n%7)

{

case 1:

s="دوشنبه";

break ;

case 2:

s="سه شنبه";

break ;

case 3:

s="چهار شنبه";

break ;

case 4 :

s="پنج شنبه";

break ;

case 5:

s="جمعه";

break ;

case 6:

s="شنبه";

break ;

default :

s="یکشنبه";

break ;

}

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

Console.ReadLine();

}

}

}

سمانه طالبی




مژده فرجی ::: سه شنبه 87/8/28::: ساعت 9:27 صبح

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

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

Console .WriteLine ("{0}",hony(n));

Console .ReadLine ();

}

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

static long hony ( int n)

{

if (n==0) return 0;

else return 2*hony (n-1)-1;

}

}

}

سمانه طالبی




مژده فرجی ::: سه شنبه 87/8/28::: ساعت 9:25 صبح

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

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

int[] a = new int[n];

Random r = new Random(4);

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

a[i] = r.Next(10, 21);

Program.write1(a);

Console .WriteLine ("max={0}\n", Program .max(a));

Console .WriteLine ("min={0}" ,Program .min(a));

 

Console .WriteLine ("sum={0}\n" ,Program .sum(a));

Console .WriteLine ("ave={0}\n" ,Program .ave(a));

 

 

Program .fibo (n);

Console .Read ();

 

}

/*************************************max*********************************************/

static int max(int[] a)

{

int m = a[0];

for (int i = 1; i < a.Length; i++)

if (a[i] > m)

 

m = a[i];

return m;

}

/*************************************min************************************************/

static int min (int[] a)

{

int m = a[0];

for (int i = 1; i < a.Length; i++)

if (a[i] < m)

 

m = a[i];

return m;

}

/****************************************sum********************************************/

static int sum (int[] a)

{

int sum = 0;

for (int i = 1; i < a.Length; i++)

sum+=a[i];

 

 

 

 

return sum;

}

/***************************************ave***********************************************/

static Double ave(int[] a)

{

int sum=0;

for (int i = 1; i < a.Length; i++)

sum+=a[i];

double ave=sum/a.Length ;

 

return ave;

}

/*****************************************writ************************************/

static void write1(int[]a)

{

for (int i = 0; i < a.Length; i++)

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

}

/**********************************fibo****************************************/

static void fibo (int n)

{

int []f =new int [n];

f[0] = 1;

f[1] = 1;

for (int i = 2; i < n; i++)

f[i] = f[i - 1] + f[i - 2];

Program.write1(f);

 

 

}

}

}

سمانه طالبی




مژده فرجی ::: سه شنبه 87/8/28::: ساعت 9:24 صبح

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

double x = Convert.ToDouble(Console.ReadLine());

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

Console.WriteLine("{0}", Program.exp1(x, n));

Console.ReadLine();

 

}

static double power(double x, int n)

{

if ((x == 0) || (x == 1)) return x;

 

 

double p = 1;

for (int i = 1; i <= n; i++)

p *= x;

return p;

}

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

static long fact(int n)

{

long f = 1;

if (n <= 1) return 1;

for (int i = 1; i <= n; i++)

f = f * i;

return f;

}

static double exp1(double x, int n)

{

double sum = 0;

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

sum += power(x, i) / fact(i);

return sum;

}

}

}

سمانه طالبی




مژده فرجی ::: سه شنبه 87/8/28::: ساعت 9:21 صبح

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

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

int sum = 0;

for (int i = 1; i < n; i++)

{

if (n % i == 0)

sum += i;

}

if (sum == n)

Console.WriteLine("tom");

else

Console.WriteLine("not tom");

Console.ReadLine();

سمانه طالبی




مژده فرجی ::: دوشنبه 87/8/27::: ساعت 7:40 عصر

   1   2      >
>> بازدیدهای وبلاگ <<
بازدید امروز: 0


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


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

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


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