Last active
October 20, 2016 10:37
-
-
Save dretax/8c9d5f86d14e7c4554aa7657b8808533 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace IziProgZH5 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string sentence = "Adjon meg egy nagyon menő, és jól kinéző mondatot!"; | |
string sentence2 = "Almát eszem"; | |
Console.WriteLine(CountWords(sentence)); | |
Console.WriteLine(GetReplacement(sentence2)); | |
Console.ReadKey(); | |
} | |
// Ez nem túl helyes, de nem volt kikötve | |
static int CountWords(string s) | |
{ | |
int c = 0; | |
foreach (var x in s.ToCharArray()) | |
{ | |
// string.IsNullOrWhiteSpace(x) | |
if (x.ToString() == " ") | |
{ | |
c++; | |
} | |
} | |
return c+1; | |
} | |
static string GetReplacement(string s) | |
{ | |
string s2 = ""; | |
foreach (var x in s.ToCharArray()) | |
{ | |
if (x.ToString().ToLower() == "a" || x.ToString().ToLower() == "á" || x.ToString().ToLower() == "e" | |
|| x.ToString().ToLower() == "é" | |
|| x.ToString().ToLower() == "i" | |
|| x.ToString().ToLower() == "í" | |
|| x.ToString().ToLower() == "ö" | |
|| x.ToString().ToLower() == "ő" | |
|| x.ToString().ToLower() == "ü" | |
|| x.ToString().ToLower() == "ű" | |
|| x.ToString().ToLower() == "u" | |
|| x.ToString().ToLower() == "ú" | |
|| x.ToString().ToLower() == "o" | |
|| x.ToString().ToLower() == "ó") | |
{ | |
s2 = s2 + x.ToString().ToLower() + "v" + x.ToString().ToLower(); | |
} | |
else | |
{ | |
s2 = s2 + x.ToString().ToLower(); | |
} | |
} | |
return s2; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment