Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program to implement the following requirement: Input: The program will read from the standard input any text up to 1 0 ,

Write a C program to implement the following requirement:
Input: The program will read from the standard input any text up to
10,000 characters.
Output: The program will sort the words in alphabetical order and
print to the standard output:
- On the first line, the sorted words separated by a comma ,.
- On the second line, the index of the sorted words separated by a
comma ,. The index start from 0.
If two words are the same, the smaller index will appear first. A word
is a string without whitespaces (space/tab/new line character).
If the input text is empty or there is no word in the input text, the
program prints nothing to stdout.
SAMPLE INPUT 1
hello World! 123
SAMPLE OUTPUT 1
123,hello,World!
2,0,1
SAMPLE INPUT 2
SAMPLE OUTPUT 2
SAMPLE INPUT 3
This is the 1ST line. This is the 2ND line.
SAMPLE OUTPUT 3
1ST,2ND,is,is,line.,line.,the,the,This,This
3,8,1,6,4,9,2,7,0,5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions