basecamper's blog

By basecamper, history, 3 years ago, In English

Hello,

I am trying to solve A. Way Too Long Words in C# (I already have a solution in c++).

https://codeforces.com/problemset/problem/71/A

I used the example given in the problem section in order to check my code. If I input n = 1 and check each string individually, I get correct answers.

When n = 4 like in the example, it gives a wrong answer.

Test: #1, time: 78 ms., memory: 0 KB, exit code: 0, checker exit code: 1, verdict: WRONG_ANSWER Input 4 word localization internationalization pneumonoultramicroscopicsilicovolcanoconiosis Output word o9nn17nn42s Answer word l10n i18n p43s Checker Log wrong answer 2nd words differ — expected: 'l10n', found: 'o9nn17nn42s'

Thank you

basecamper

using System;

namespace Way_Too_Long_Words

{

class Program { static void Main(string[] args)

{
        int n;

        n = int.Parse(Console.ReadLine());

        int i = 1;

        while (i <= n)
        {
            string inputName = Console.ReadLine();

            if (inputName.Length > 10)
            {
                Console.Write(inputName[0]); Console.Write(inputName.Length - 2); Console.Write(inputName[inputName.Length - 1]);
                Console.Read();
            }
            else
            {
                Console.WriteLine(inputName);
                Console.Read();
            }

            i++;
        }
    }
}

}

  • Vote: I like it
  • -15
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it -10 Vote: I do not like it

It was my solve for that problem:

using System; namespace myProgram {

class Program
{
    public static void Main(String[] args)
    {
        int a = int.Parse(Console.ReadLine());
        if (a >= 1 && a <= 100)
        {
            for (int i = 0; i < a; i++)
            {
                string b = Console.ReadLine();
                int c = (b.Length);
                int d = c - 2;
                if (c >= 1 && c <= 100)
                {
                    if (c <= 10)
                    {
                        Console.WriteLine(b);
                    }
                    else
                    {
                        Console.WriteLine(b[0] + "" + d + "" + b[c - 1]);
                    }
                }
            }
        }
    }
}

}