ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Linear Data Structures: Arrays > задача:


51246 - Swap largest word, reverse the rest

Задачи раздела

• 51175 Question 2
• 51093 - rgb2gray
• 51092 - Even and Odd
• 51095 - Normal and Trace
• 50382 - Parkside's Other Triangle
• 50383 - Noisy Mornings
• 51097 - Sum of Borders
• 51129 - Hexagon
• 51246 - Swap largest word, rev...
• 50431 - Sultan's Game
• 50420 - Teachers Sightseeing
• 50977 - Gaussian Elimination
• 50395 - Page "Like" Averages
• 50516 - Lines
• 50446 - Snake
• 50345 - Orders
• 51127 - Maze solver

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ismail Shpati.

Swap largest word, reverse the rest

Question: A line of text will be given. You will have to do the following modifications to this line of text:

  • Swap the largest word, with the smallest one (smallest word must have more than 2 characters; length > 2).
  • If there are two or more words with the same length, take the first instance.
  • Reverse the rest of the words that have more than 3 characaters (length > 3).
  • There will be punctutation marks at the end of some words (" . " " , " " ! " " ? " " ; " " : "). They shouldn't be calculated in the length of the word.
  • The punctuation mark should remain at the end of the word even if the word is reversed. (ex. word. => drow.)

Input specification: You will be given one line of text. (maximum length of the line 300 characters; maximum length of a word 20 characters)

Output specification: Show the modified line of text (Note: there shouldn't be a space at the end of the line)

Sample Input I
Andy went, to the park.
Sample Input II
Scattering around, did not bring much joy.
Sample Output I
the tnew, to Andy krap.
Sample Output II
did dnuora, Scattering not gnirb hcum joy.

Sample Input I Explanation: At the first input, we have 3 words with the length of 4 which also is the max length (Note: "went" and "park" both have a punctuation mark at the end but it isn't calculated in the length of the word). We take the first instance, which is "Andy" and swap it with "the" which is the smallest word with a length greater than 2. The rest of the words are reversed without moving the punctuation mark. (went, => tnew,)

 
Для отправки решений необходимо выполнить вход.

www.contester.ru