Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
esimerkit
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
tie
ohj1
2023s
esimerkit
Commits
34be944b
Commit
34be944b
authored
1 year ago
by
Vesa Lappalainen
Browse files
Options
Downloads
Patches
Plain Diff
live15 loppu
parent
c660ad5b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
luennot/live15/Listat/Listat.cs
+4
-22
4 additions, 22 deletions
luennot/live15/Listat/Listat.cs
with
4 additions
and
22 deletions
luennot/live15/Listat/Listat.cs
+
4
−
22
View file @
34be944b
using
System
;
using
System.Text
;
using
System.Linq
;
using
System.Collections.Generic
;
// ReSharper disable RedundantAssignment
/// @author Vesa Lappalainen
/// @version 22.10.2023
...
...
@@ -51,7 +51,7 @@ public class Listat
int
lkm5
=
LaskeLuvut
(
lista
,
5
);
lkm5
=
lista
.
Sum
(
Onko5
);
lkm5
=
lista
.
Sum
(
delegate
(
int
a
)
{
if
(
a
==
5
)
return
1
;
return
0
;
});
lkm5
=
lista
2
.
Sum
(
a
=>
a
==
5
?
1
:
0
);
// lambda lauseke
lkm5
=
lista
.
Sum
(
a
=>
a
==
5
?
1
:
0
);
// lambda lauseke
if
(
lkm5
>
5
)
{
}
...
...
@@ -65,26 +65,6 @@ public class Listat
/// <summary>
/// Etsitään taulukosta montako pyydytettyä lukua siellä on.
/// </summary>
/// <param name="luvut">taulukko josta etsitään</param>
/// <param name="mitaEtsitaan">etsittävä luku</param>
/// <returns>montako etsittävää löytui</returns>
/// <example>
/// <pre name="test">
/// int[] luvut = {1,2,3,4,3,2,0};
/// LaskeLuvut(luvut,5) === 0;
/// LaskeLuvut(luvut,3) === 2;
/// LaskeLuvut(luvut,1) === 1;
/// LaskeLuvut(new int[]{},1) === 0;
/// </pre>
/// </example>
public
static
int
LaskeLuvut
(
int
mitaEtsitaan
)
{
return
LaskeLuvut
(
null
,
mitaEtsitaan
);
}
/// <summary>
/// Etsitään taulukosta montako pyydytettyä lukua siellä on.
/// </summary>
...
...
@@ -116,6 +96,8 @@ public class Listat
lkm
++;
return
lkm
;
}
/// <summary>
/// Etsitään taulukon suurin
/// </summary>
...
...
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