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

Разделы > Сортировка и последовательности > задача:


50311 - Student Line Up

Гость
• Вопросы к жюри (1)

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

• 50906 - The Smallest Pair
• 50730 - The largest product
• 50731 - The largest product (2)
• 50732 - Sorting
• 50549 - k-Nearest Neighbours (kNN)
• 50290 - Minimax Sum
• 50738 - Median value
• 50317 - Student Line Up
• 50311 - Student Line Up
• 50320 - Random Sorted List
• 50736 - Top N Donors - 2
• 50733 - The Highest Average
• 50364 - Student averages
• 50333 - Series of Squares
• 50734 - Product Info (In Srt)
• 50735 - Top M Products
• 50339 - The Largest Rectangle

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

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

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Prepared by Halil Karimis.

Student Line Up

A teacher has asked all her students to line up single line according to their first name. For example, in one class Amy will be at the front of the line and Yolanda will be at the end.

Question: Write a program that prompts the user to enter the number of students in the class, and then loops to read in that many names. Once all the names have been read in, the program reports which student would be at the front of the line and which one would be at the end of the line.

Input specification
The program will get the a number (n) first, and then it gets n names which are all string at most with 16 chars and 1 < n ≤ 100.

Output specification
Print out just two names which are the first and the last students in the class.

 Sample Run I  
  7
  Sabina
  Beki
  Nilda
  Elton
  Xheni
  Bajram
  Enea

 Sample Output I  
  Bajram
  Xheni

 Sample Input II  
  5
  Yolanda
  Erind
  Amy
  Ardit
  Ledio

 Sample Output II  
  Amy
  Yolanda

 Sample Explanation  
"Beki" and "Bajram" both start with 'B' letters but "Bajram" is before "Beki". In C++, you can compare strings as you compare integers. For example, if name1 and name2 are string variables
   string name1="Beki", name2="Bajram";

when you compare them in your code,
   if(name1 < name2) ...

It will produce false result for the comparision there because "Beki" (according to ASCII values) is greater than "Bajram".


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

www.contester.ru