blob: 118a1cab03dae9db8fd203b5b3083334367b0549 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
Assignment name : ord_alphlong
Expected files : *.c, *.h
Allowed functions: write, malloc, free
--------------------------------------------------------------------------------
Write a program that takes a string as a parameter and prints its words sorted
in length order then in alphabetical order: when words are alphabetically
equals (for example aA and Aa), original order must remain (lower and upper
case are the same in alphabetical order). If there are duplicates, they must
remain.
If number of parameters is different from 1, the program prints
\n.
There will be only spaces, tabs and alphanumeric caracters in strings.
You'll print only one space between each word. Nothing before the first and
after the last word of each line.
Examples:
$>./ord_alphlong
$
$>./ord_alphlong "After all this time Always said Snape" | cat -e
all$
said this time$
After Snape$
Always$
$>./ord_alphlong "A a b B cc ca cd" | cat -e
A a b B$
ca cc cd$
$>./ord_alphlong "Never take a gamble you are not prepared to lose" | cat -e
a$
to$
are not you$
lose take$
Never$
gamble$
prepared$
$>
|