0

I need to write a program, that lists keystrings for each command for a given set of commands.


Input

The first line contains the number n of commands for the console application.

Each of the following n lines contains one command of the client.

Each command is a nonempty string consisting of lowercase Latin letters and its length is at most 100.

No command is a proper substring of another command.

Output

Output n lines.

The i-th line should contain any of the shortest key substrings of the i-th command (the commands are numbered in the order they are given in the input).

Sample

input output

3

abcm ab

acm ac

bcd d

abd abd


I first need to know how to split a string like "abcd" into a b c d separately. I can't use strtok() because it take a delimiter like space, comma or hyphen etc. I can't use delimiters within the same word. Please help me out.

Thanks,
Kahaly

Edited by kahaly: n/a

2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by myk45
0

>>I first need to know how to split a string like "abcd" into a b c d separately

Why don't you use an index? What i mean is,

char letterArray[100];
for (i = 0; i < strlen(str); i++) {
    letterArray[i] = str[i];
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.