Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
WayeKids
w4b
Commits
f6b96661
Commit
f6b96661
authored
Mar 27, 2017
by
Nydal EL-KABIR
Browse files
test pour les tableaux et les listchainées
parent
8158c912
Changes
2
Hide whitespace changes
Inline
Side-by-side
ProjetW4b/ProjetW4b/progList.cs
View file @
f6b96661
...
...
@@ -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
,
Linked
List
<
uint
>
list
,
uint
length
)
{
for
(
uint
i
=
0
;
i
<
length
;
i
++)
{
list
.
Add
((
uint
)
r
.
Next
());
list
.
Add
Last
((
uint
)
r
.
Next
());
}
}
static
void
writeList
(
List
<
uint
>
list
)
static
void
writeList
(
Linked
List
<
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
());
}
}
}
ProjetW4b/ProjetW4b/progTab.cs
View file @
f6b96661
...
...
@@ -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
(
IndexOutOfRange
Exception
)
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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment