Commit f6b96661 authored by Nydal EL-KABIR's avatar Nydal EL-KABIR
Browse files

test pour les tableaux et les listchainées

parent 8158c912
......@@ -8,29 +8,72 @@ namespace ProjetW4b
{
class progList
{
/*static void Main(string[] args)
static void Main(string[] args)
{
List<uint> listInteger = new List<uint>();
Random r = new Random();
addToList(r, listInteger, uint.Parse(args[0]));
writeList(listInteger);
Console.ReadKey(true);
}*/
try
{
LinkedList<uint> listInteger = new LinkedList<uint>();
Random r = new Random();
addToList(r, listInteger, uint.Parse(args[1]));
if (uint.Parse(args[0]) == 1)
{
writeList(listInteger);
Console.ReadKey(true);
}
else if(uint.Parse(args[0]) == 2)
{
getIntList(listInteger, uint.Parse(args[2]));
Console.ReadKey(true);
}
else if(uint.Parse(args[0]) == 3)
{
deleteFromList(listInteger, uint.Parse(args[2]));
Console.ReadKey(true);
}
Console.ReadKey(true);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine("usage: progTab op1 op2 op3");
Console.WriteLine("op1: 1 ajout, 2 recherche, 3 suppression, op2: taille, op3: nbRechercher ou a supprimer");
Console.ReadKey(true);
}
}
static void addToList(Random r, List<uint> list, uint length)
static void addToList(Random r, LinkedList<uint> list, uint length)
{
for(uint i=0; i<length; i++)
{
list.Add((uint)r.Next());
list.AddLast((uint)r.Next());
}
}
static void writeList(List<uint> list)
static void writeList(LinkedList<uint> list)
{
foreach(uint i in list)
{
Console.Write(i + " ");
}
}
static void getIntList(LinkedList<uint> list, uint nb)
{
//Console.WriteLine(list.Last.Value.ToString());
if (list.Find(nb) != null)
{
Console.WriteLine("Valeur trouvee");
}
else
{
Console.WriteLine("Valeur non trouvee");
}
}
static void deleteFromList(LinkedList<uint> list, uint nb)
{
Console.WriteLine("Résultat de la suppression: " + list.Remove(nb).ToString());
}
}
}
......@@ -8,7 +8,7 @@ namespace ProjetW4b
{
class progTab
{
static void Main(string[] args)
/*static void Main(string[] args)
{
try
{
......@@ -17,14 +17,12 @@ namespace ProjetW4b
if (uint.Parse(args[0]) == 1)
{
addToTab(r, tabInt);
writeTab(tabInt);
Console.ReadKey(true);
}
else if (uint.Parse(args[0]) == 2)
{
addToTab(r, tabInt);
writeTab(tabInt);
getIntFromTab(tabInt, uint.Parse(args[2]));
Console.ReadKey(true);
}
......@@ -35,12 +33,14 @@ namespace ProjetW4b
Console.ReadKey(true);
}
}
catch(IndexOutOfRangeException)
catch(Exception e)
{
Console.WriteLine(e.ToString());
Console.WriteLine("usage: progTab op1 op2 op3");
Console.WriteLine("op1: 1 ajout, 2 recherche, 3 suppression, op2: taille, op3: nbRechercher ou a supprimer");
Console.ReadKey(true);
}
}
}*/
static void addToTab(Random r, uint[] tab)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment