Lexicographically Sorted Words

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

jsumabat was given a problem from his computer science teacher. The problem is as follows:

Write a program that will sort a grocery list, entered by the user, into alphabetical order.

Input Specification

The first line of input will be a positive integer N (1 \le N \le 100), denoting the number of items on the list.

The next N lines will contain N single-word strings, each containing only letters of the alphabet that are lower case.

The string length, S, will have the constraints of 1 \le S \le 100.

Output Specification

Output N lines, each line containing an item in the grocery list, sorted.

Sample Input

5
apples
parmesan
driedfigs
babycarrots
pitabread

Sample Output

apples
babycarrots
driedfigs
parmesan
pitabread

Comments


  • -4
    Li_Zhang  commented on Oct. 4, 2019, 9:47 p.m.

    There is an extra whitespace in the sample output for line 2 "baby carrots" instead of "babycarrots."


    • -2
      jsumabat  commented on Oct. 5, 2019, 8:29 p.m.

      Fixed, sorry about the mistake.