Member 14073005 Ответов: 1

У меня есть задание, и я застрял в нем. Может ли кто - нибудь помочь мне решить эту проблему?


Привет. Задача такова:

Your task is to translate a message in some alien language (let's call it Alienski).

The message could be created by following simple rules and from two known languages, English and Spanish.

Each word in Alienski is constructed by subtracting the letters from English and Spanish (absolute value) and that is the resulting letter.

There are two special cases. If in each of the words the symbol is '-' (hyphen) or ' ' (space) it is mandatory for it to be kept this way.

There won't be a case with a '-' (hyphen) and a ' ' (space) at the same time.

If one of the words is with more letters than the other just add the letters from the longer word to the result.

Example:
Copy
talk
hablar
Copy
a b c d....
0 1 2 3....
t - h = | 19 - 7 | = 12 = m
a - a = | 0 - 0 | = 0 = a
l - b = | 11 - 1 | = 10 = k
k - l = | 10 - 11 | = 1 = b
empty - a = a
empty - r = r

Result:

makbar
Input:
Read from the standard input:

Two lines with messages in English and Spanish
Each message is on new line.
Output:
Print on the standard output:

On the single line of the output, print the decoded message in Alienski
Constraints:
All the letters will be small letters from the Latin alphabet and the special symbols '-' (hyphen) and ' ' (space).
Hint
Use the ASCII table
'a' - 'a' = 0
Sample tests:
Input
Copy
thank you
muchas gracias
Output
Copy
hncgk  idacias
Note: There are two spaces here

Input:

test
el examen
Output

ph pxamen


Что я уже пробовал:

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

namespace Task2
{
    class Program
    {
        static void Main(string[] args)
        {
            string english = Console.ReadLine();
            string spanish = Console.ReadLine();
            string result = string.Empty;
            char c;
            int i = 0, j = 0;
            while (i < english.Length && j < spanish.Length)
            {
                c = (char)('a' + Math.Abs(english[i] - spanish[i]));
                result += c;
                i++;
                j++;
            }
            while (i < english.Length)
            {
                result += english[i];
                i++;
            }
            while (j < spanish.Length)
            {
                result += spanish[j];
                j++;
            }
            Console.WriteLine(result);
        }
    }
}

F-ES Sitecore

Это не задание, это домашнее задание, и мы не склонны делать домашнее задание других людей, так как таким образом вы ничего не узнаете.

1 Ответов

Рейтинг:
1

OriginalGriff

Мы не делаем домашнее задание: оно задано не просто так. Она существует для того, чтобы вы думали о том, что вам сказали, и пытались понять это. Он также существует для того, чтобы ваш наставник мог определить области, в которых вы слабы, и сосредоточить больше внимания на корректирующих действиях.

Попробуйте сами, возможно, вы обнаружите, что это не так сложно, как вы думаете!

Если вы столкнетесь с конкретной проблемой, то, пожалуйста, спросите об этом, и мы сделаем все возможное, чтобы помочь. Но мы не собираемся делать все это для вас!