Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TD_debug
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FUSCIELLO Baptiste
TD_debug
Commits
49bcd31a
Commit
49bcd31a
authored
2 weeks ago
by
FUSCIELLO Baptiste
Browse files
Options
Downloads
Patches
Plain Diff
ajout de l'exercice 7
parent
ee4f907f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exo7_debug.ts
+34
-0
34 additions, 0 deletions
exo7_debug.ts
with
34 additions
and
0 deletions
exo7_debug.ts
0 → 100644
+
34
−
0
View file @
49bcd31a
multiplierParAddition
(
5
,
-
3
);
function
multiplierParAddition
(
x
:
number
,
y
:
number
):
number
{
let
val
=
0
;
// Si y est négatif, on le rend positif et on inverse le signe de x
if
(
y
<
0
)
{
y
=
-
y
;
x
=
-
x
;
}
// Optimisation : toujours boucler sur le plus petit nombre
if
(
y
<
x
)
{
[
x
,
y
]
=
[
y
,
x
];
}
console
.
log
(
`Valeurs utilisées pour la boucle : x =
${
x
}
, y =
${
y
}
`
);
for
(
let
i
=
0
;
i
<
y
;
i
++
)
{
val
+=
x
;
}
return
val
;
}
// Tests avec les cas donnés
const
testCases
:
[
number
,
number
][]
=
[
[
0
,
0
],
[
5
,
3
],
[
3
,
5
],
[
-
5
,
-
2
],
[
-
2
,
-
5
],
[
-
74
,
2
],
[
-
1
,
75
],
[
10
,
-
25
],
[
10
,
-
3
]
];
testCases
.
forEach
(([
x
,
y
])
=>
{
const
result
=
multiplierParAddition
(
x
,
y
);
console
.
log
(
`multiplierParAddition(
${
x
}
,
${
y
}
) =
${
result
}
`
);
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment