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 1601. AntiCAPS

с#,4 и 21 тестs
Posted by Sergey 3 Jan 2015 21:07
not 21 passes test:

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main()
        {
            var f = Console.In.ReadToEnd();
            f = f.ToLower();
            var b = f.ToCharArray();
            string c = "";
            c += b[0].ToString().ToUpper();
            for (var i = 1; i < b.Length - 3; i++)
            {
                if ((i + 1 != b.Length && (b[i] == '!' || b[i] == '?' || b[i] == '.'||b[i] == '-') && (b[i+3] != '-'&&b[i + 1] != '!' && b[i + 1] != '?' && b[i + 1] != '.')))

                {
                    c += b[i];
                    i++;
                    while (b[i] == ' ' || b[i] == '\t' || b[i] == '\r' || b[i] == '\n')
                    {
                        c += b[i];
                        if (i + 1 != b.Length)
                            i++;
                        else break;
                    }
                    c += b[i].ToString().ToUpper();
                }
                else
                    c += b[i];
            }


            Console.WriteLine(c);
        }
    }
}



not 4 passes test:

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main()
        {
            var f = Console.In.ReadToEnd();
            f = f.ToLower();
            var b = f.ToCharArray();
            string c = "";
            for (var i = 1; i < b.Length - 1; i++)
            {
                if (b[i - 1] == '-')
                    i--;
                if ((i + 1 != b.Length && i + 2 != b.Length && i + 3 != b.Length && (b[i] == '!' || b[i] == '?' || b[i] == '.' || b[i] == '-') && (b[i + 3] != '-' && b[i + 1] != '!' && b[i + 1] != '?' && b[i + 1] != '.')))
                {

                    c += b[i];
                    i++;
                    while (b[i] == ' ' || b[i] == '\t' || b[i] == '\r' || b[i] == '\n')
                    {
                        c += b[i];
                        if (i + 1 != b.Length)
                            i++;
                        else break;
                    }
                    c += b[i].ToString().ToUpper();
                }
                else
                {
                    if (i == 1)
                        c += b[i - 1].ToString().ToUpper();

                    c += b[i];
                }
            }


            Console.WriteLine(c);
        }
    }
}

Edited by author 03.01.2015 21:08
Re: с#,4 и 21 тестs
Posted by Desserg 3 Dec 2019 14:01
- IS IT CORRECT?
- YES, IT IS.

- Is it correct?
- Yes, it is.
Мне этот пример помог 21 тест пройти
Re: с#,4 и 21 тестs
Posted by Neko_r_The_Best 5 Sep 2022 22:27
If you have this problem - remember that a sentence is ended only with "!?."
Endline is not an end of a sentence