ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1038. Spell Checker

C# RULEZ :)
Posted by Zadrot 13 Mar 2007 01:49
using System;
using System.Collections.Generic;
using System.Text;

namespace Timus
{
class Program
    {
        static void Main()
        {
            int mistakes = 0;
            string text = "";
            while (true)
            {
                string s = Console.ReadLine();
                if (s == null) break;
                text += ' ' + s;
            }

            string[] sentence = text.Split(new char[] { '!', '?', '.' }, StringSplitOptions.RemoveEmptyEntries);
            string[] words = text.Split(new char[] { ' ', '.', ' ', ',', ';', ':', '-', '!', '?'}, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < sentence.Length; i++)
            {
                sentence[i] = sentence[i].Trim();
                if (sentence[i].Length > 0 && 'a' <= sentence[i][0] && sentence[i][0] <= 'z')
                    mistakes++;
            }

            for (int i = 0; i < words.Length; i++)
                for (int j = 1; j < words[i].Length; j++)
                    if ('A' <= words[i][j] && words[i][j] <= 'Z')
                        mistakes++;

            Console.WriteLine(mistakes);
        }
    }
}

Sorry for posting code, but maybe anybody try to write on C# after this post.

Edited by author 13.03.2007 01:53