- Write A C Progran To Implement The Following Requirement Input The Program Will Read From The Standard Input Any Text 1 (36.89 KiB) Viewed 28 times
Write a C progran to implement the following requirement: Input: The program will read from the standard input any text
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Write a C progran to implement the following requirement: Input: The program will read from the standard input any text
Write a C progran to implement the following requirement: Input: The program will read from the standard input any text up to 10,000 characters. Output: The progran will sort the words in alphabetical order and print to the standard output: On the first line, the sorted words separated by a conna, On the second line, the index of the sorted words separated by a comma",". The index start from . It two words are the same, the smaller index will appear first. (A word is a string without whitespaces (space/tab/new line character)) Note: It the input, textos empty or there is no word in the input text, the program must print the enpty string to stdout. Requirements: Use the following struct to store the word and its index: struct WORD char *5: int index: } YOU MUST use pointer to do the sorting. It you don't use pointer, you will get 6. SAMPLE INPUT 1 hello world! 123 SAMPLE OUTPUT 1 123, hello, World! 2,8,1 SAMPLE INPUT 2 cempty SAMPLE OUTPUT 2 cempty> SAMPLE INPUT 3 This is the 1ST line. This is the 2ND line. SAMPLE OUTPUT 3 IST, 2ND, 1s, is, line., line.,the, the, This, This 3,8,1,6,4,9,2,7,0,5