Created
October 26, 2016 11:11
-
-
Save s0ren/3c6a81b13b040e73b0903268d8a2b8ec to your computer and use it in GitHub Desktop.
Tæl ord og punktummer mv, og beregn LIX tal.
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; | |
using System.Threading.Tasks; | |
namespace Lix | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string text = @"Det opgøres som det gennemsnitlige antal ord pr. helsætning, | |
plus procentdelen af lange ord, | |
altså ord der er over seks bogstaver lange."; | |
text = @"Der var engang | |
en mand. Han boede i en spand."; | |
//text = @""; | |
int antalOrd; | |
int antalPunktummer = 0; | |
int antalLangeOrd = 0; | |
char[] adskillere = { ' ', '\n' }; | |
string[] Ordene = text.Split(adskillere); | |
foreach(string ordet in Ordene) | |
{ | |
Console.WriteLine(ordet); | |
} | |
Console.WriteLine("Der er {0} ord i.", Ordene.Length); | |
antalOrd = Ordene.Length; | |
foreach(char tegn in text) | |
{ | |
if (tegn == '.') | |
{ | |
antalPunktummer++; | |
} | |
} | |
Console.WriteLine("Der er {0} punktumer i text", antalPunktummer); | |
char[] adskillere2 = { ' ', '\n', '.',',','!','?' }; | |
string[] langeOrdene = text.Split( adskillere2 ); | |
foreach(string langtOrd in langeOrdene) | |
{ | |
if (langtOrd.Length > 6) | |
{ | |
antalLangeOrd++; | |
} | |
} | |
int lix = antalOrd / antalPunktummer + (antalLangeOrd * 100) / antalOrd; | |
Console.WriteLine("Lix tallet er: " + lix); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment