Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Prog1_WS2017_18_Wienkop
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Uwe Wienkop
Prog1_WS2017_18_Wienkop
Commits
f9fc03e8
Commit
f9fc03e8
authored
Nov 06, 2017
by
Uwe Wienkop
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
String-Funtionen Reverse, IstPalindrom
parent
28ea07e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
4 deletions
+29
-4
Prog1_WS2017-18/05Character/Program.cs
Prog1_WS2017-18/05Character/Program.cs
+29
-4
No files found.
Prog1_WS2017-18/05Character/Program.cs
View file @
f9fc03e8
...
...
@@ -35,16 +35,17 @@ namespace _05Character
string
s1
=
"Hallo Welt"
;
Console
.
WriteLine
(
ToUpper
(
s1
));
//if (s1 < s2)
s1
=
"RELIEFPFEILER"
;
Console
.
WriteLine
(
$"Ist
{
s1
}
ein Palindrom =>
{
istPalindrom
(
s1
)}
"
);
Console
.
WriteLine
(
Reverse
(
"ABCD"
));
}
static
int
CompareTo
(
string
s1
,
string
s2
)
{
// 0 --> s1 == s2
// >0 --> s1 > s2
// <0 --> s1 < s2
{
int
minZeichen
;
// Länge der kürzeren Zeichenkette bestimmen
if
(
s1
.
Length
<
s2
.
Length
)
minZeichen
=
s1
.
Length
;
...
...
@@ -74,9 +75,33 @@ namespace _05Character
if
(
c
>=
'a'
&&
c
<=
'z'
)
sErg
+=
(
char
)
(
c
-
32
);
// (char) unbedingt notwendig, sonst
else
// werden die Zahlenwerte gespeichert
sErg
+=
c
;
sErg
=
sErg
+
c
;
}
return
sErg
;
}
static
string
Reverse
(
string
zeichenkette
)
{
string
sErg
=
""
;
foreach
(
char
zeichen
in
zeichenkette
)
{
sErg
=
sErg
+
zeichen
;
}
return
sErg
;
}
static
bool
istPalindrom
(
string
s
)
{
int
i
=
0
,
j
=
s
.
Length
-
1
;
while
(
i
<
j
)
{
if
(
s
[
i
]
!=
s
[
j
])
return
false
;
i
++;
j
--;
}
return
true
;
}
}
}
Write
Preview
Markdown
is supported
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