سلام دوستان تمرین ها را می گذارم استفاده نمایید :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace arezoo0oo
{
class Program
{
static void Main(string[] args)
{
int i, n;
Console.Write("enter your number:");
n = int.Parse(Console.ReadLine());
for (i = 1; i <= n; i++)
Console.WriteLine("number is:{0}", i);
Console.ReadLine();
}
}
}
-------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace arezoo1
{
class Program
{
static void Main(string[] args)
{
int n, a, max, count;
count = 0;
Console.Write("Enter Number of your numbers:");
n = int.Parse(Console.ReadLine());
Console.Write("enter number:");
a = int.Parse(Console.ReadLine());
max = a;
if (a % 2 == 1)
count++;
for(int i=2; i<=n; i++)
{
Console .Write ("enter number;");
a=int .Parse (Console .ReadLine ());
if(a>max)
max=a;
if(a%2==1)
count++;
Console .WriteLine ("max is:{0} and count of odd number is :{1}", max,count);
}
Console .ReadLine ();
}
}
}
----------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace barname
{
class Program
{
static void Main(string[] args)
{
int i, j, n;
Console.Write("enter n:");
n = int.Parse(Console.ReadLine());
Console.Write("\n\n----------------------------------------------\n\n");
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write("@");
}
Console.Write("\n");
}
Console.Write("\n\`n----------------------------------------------\n\n");
Console.ReadLine();
}
}
}
-----------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace barname
{
class Program
{
static void Main(string[] args)
{
int i, j, n;
Console.Write("enter n:");
n = int.Parse(Console.ReadLine());
Console.Write("\n\n----------------------------------------------\n\n");
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n; j++)
{
Console.Write("@");
}
Console.Write("\n");
}
Console.Write("\n\`n----------------------------------------------\n\n");
Console.ReadLine();
}
}
}
-----------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace barname
{
class Program
{
static void Main(string[] args)
{
int i, j, n;
Console.Write("enter n:");
n = int.Parse(Console.ReadLine());
Console.Write("\n\n----------------------------------------------\n\n");
for (i = 1; i <= n; i++)
{
for (j = i; j <= n; j++)
{
Console.Write("@");
}
Console.Write("\n");
}
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write("@");
}
Console.Write("\n");
}
Console.Write("\n\n----------------------------------------------\n\n");
Console.ReadLine();
}
}
}
---------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace test2
{
class Program
{
static void Fact(int n)
{
int p=1;
for (int i =1 ; i<=n;i++)
{
p*=i;
}
Console .Write (" Fact of {0} is {1}",n,p);
}
static void CountofThree(int n)
{ int Count=0;
for(int i=3;i <=n; i+=3)
{
Count++ ;
}
Console .Write (" Count of Three is {0}",Count);
}
static void Maghsom(int n)
{
for (int i = 2; i <= n / 2; i++)
{
if (n % i == 0)
Console.Write("{0},", i);
}
}
static void Main(string[] args)
{
int n;
char option;
bool play=true;
while (play)
{
Console.Write(" enter n:");
n = int.Parse(Console.ReadLine());
Console.Write("\n\n---------------------------------------\n\n");
Console.Write("\n\n---------------------------------------\n\n");
Console.WriteLine("Choose F to run FACT ");
Console.WriteLine("Choose C to run Count of Three");
Console.WriteLine("Choose M to run Maghsom ");
Console.Write("\n\n---------------------------------------\n\n");
Console.Write("\n\n---------------------------------------\n\n");
Console.WriteLine("Now what is your choose ? ");
option = Char.Parse(Console.ReadLine());
if (option == 'F' || option == 'f')
Fact(n);
if (option == 'C' || option == 'c')
CountofThree(n);
if (option == 'M' || option == 'm')
Maghsom(n);
Console.WriteLine("\n etekhabe digei mikhay dashte bashi?: y or n");
option = Char.Parse(Console.ReadLine());
if (option == 'N' || option == 'n')
play = false;
}
// Console.ReadLine();
}
}
}
--------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace barname77
{
class Program
{
static void Main(string[] args)
{
Random rand = new Random();
int RandomNum, Guess, i;
Console.WriteLine("question Game is starting......");
Console.Write("\n\n---------------------------------\n\n");
Console.WriteLine("Computer Selected a Random Number between 0 to 10000");
RandomNum = rand.Next(10001);
for (i = 1; i <= 20; i++)
{
Console.Write("Enter your " + i + "'s Guess:");
Guess = Convert.ToInt16(Console.ReadLine());
//Cheking RandomNum with Guess
if (Guess == RandomNum)
{
Console.Write("\n you win ........\n");
break;
}
else if (Guess > RandomNum)
{
Console.WriteLine("\n\n you selected a Higher choice....!select Lower one.");
}
else
{
Console.WriteLine("\n\n you selected a lower choice....!select Higher.");
}
}
//cheking that i win or loose!
if (i > 20)
{
Console.Write("\n you loose..!!My selected Number is" + RandomNum + "\n");
}
Console.ReadLine();
}
}
}
------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void CountofSpace(String str)
{
int Count = 0;
for (int i = 0; i < str.Length; i++)
{
if (str[i] == ' ')
{
Count++;
}
}
Console.Write("\n----\nCountof space is :" + Count);
}
static void ReplacespaceWithstar(string str)
{
str=str.Replace(' ','*');
Console.Write("\n....\nstring is:"+str);
}
static void showMenu()
{
Console.WriteLine("press 1 to run count of spaces");
Console.WriteLine("press 2 to run Rwplace spaces with stars");
Console.WriteLine("Now what is your choice?...");
}
static void Main(string[] args)
{ string Mystring;
int option;
Console.Write("Enter your string:");
Mystring=Console.ReadLine();
L1:showMenu();
option=Convert.ToInt16(Console.ReadLine());
switch(option)
{
case 1:CountofSpace(Mystring);break;
case 2:ReplacespaceWithstar(Mystring);break;
default:Console.WriteLine("wrong choice...!select Again.");goto L1;
}
Console.ReadLine();
}
}
}