Sei sulla pagina 1di 4

Ex1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace exercice_n1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("donner l'entier :");
int i = Int32.Parse(Console.ReadLine());
Console.WriteLine("l'entier est : " + i);
Console.ReadLine();
}
}
}

Ex 2

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace exercice_n2
{
class Program
{
static void CreeTableau()
{
int[] t = new int[5];
for (int i = 0; i < t.Length; i++)
{
Console.Write(" t[" + i + "] = ");
t[i] = Int32.Parse(Console.ReadLine());

}
for (int i = 0; i < t.Length; i++)
{
Console.Write(t[i]+ "+");
}
int Som = 0;
for (int i = 0; i < t.Length; i++)
{
Som += t[i];
}
Console.Write("=" +Som);
}

static void Main(string[] args)


{
CreeTableau();
Console.ReadLine();

}
}
}

Ex 3

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace exerciece_n3
{
class Program
{
static void semaine ()
{
List<string> jours = new List<string> { "Lundi", "Mardi", "Mercredi",
"Jeudi", "Vendredi", "Samedi", "Dimanche" };
foreach (string jour in jours)
{
Console.WriteLine(jour);
}
Console.Write("donner la position du jour a supprimer :");
int i;
jours.RemoveAt(i = Int32.Parse(Console.ReadLine()));
foreach (string jour in jours)
{
Console.Write(jour + " ");
}
Console.Write(" indice de jeudi :");
int indice = jours.IndexOf("Jeudi");
Console.WriteLine(indice);
}
static void Main(string[] args)
{
semaine();
Console.ReadLine();
}
}
}

Ex4

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace exercice_n4
{
class Program
{
static void Main(string[] args)
{
string mDate = DateTime.Now.ToString();
string mYear = DateTime.Now.Year.ToString();
string mMonth = DateTime.Now.Month.ToString();
string mDay = DateTime.Now.Day.ToString();
string mHoure = DateTime.Now.Hour.ToString();
string mMinute = DateTime.Now.Minute.ToString();
string mSecond = DateTime.Now.Second.ToString();
string mMillisecond = DateTime.Now.Millisecond.ToString();
string mSdate = DateTime.Now.ToShortDateString();
Console.WriteLine(
"\n complete date: " + mDate +
"\n year: " + mYear +
"\n month: " + mMonth +
"\n day: " + mDay +
"\n houre: " + mHoure +
"\n minute: " + mMinute +
"\n second: " + mSecond +
"\n millisecond: " + mMillisecond +
"\n short date: " + mSdate);
Console.ReadLine();
}
}
}

Ex7

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace exercice_n7
{
class Program
{
static void Main(string[] args)
{
string str= " C# programming 2017 or Csharp programming 2017 ";
int longueurChaine = str.Length;
Console.WriteLine("la longeure du chaine: "+ longueurChaine);
int indexC = str.IndexOf("C");
int indexc = str.LastIndexOf("C");
Console.WriteLine("La position du premiere occ de c est: " + indexC +
"\nLa position du derniere occ de c est: " + indexc);
string chaineNettoyée = str.Trim();
Console.WriteLine(str);
Console.WriteLine(chaineNettoyée);
string sousChaine = str.Substring(1, 3);
Console.WriteLine(sousChaine);
int k = 0;
foreach (var c in str)
{
if (char.IsNumber(c))
{
k++;
}
}
Console.WriteLine("le nombre de chiffres dans la chaine est: "+k);
Console.ReadLine();
}
}
}

Potrebbero piacerti anche