Problem-solving report to find the smallest string

Author: Zhang Yong
Unit: Zhejiang University City College
Time limit: 400 ms
Memory Limit: 64 MB
Code length limit: 16 KB
1. This question requires programming, for N input string, the smallest output string.
Input format:
input of the first row is given a positive integer N; followed by N rows, each row is given a non-empty string length of less than 80, wherein the line break does not occur, spaces, tabs.
Output format:
the format of the output in line with the smallest string:
Min IS: minimum string
Input Sample:
. 5
of Li
Wang
Zha
Jin
Xian
Output Sample:
Min IS: Jin
2. solving algorithms:
Define a storage pointer array input string, a minimum string-dimensional array stored to find a re-definition of
the flowchart:

3. solving difficulties:
when the dynamic open space open space is too small, a large n, the shortest string containing the longest points fails the test .
Solution: When you open a dynamic space sizeof (char) n, n as large as that.
4. core code:
for (I = 0; I <n-; I ++) {
S [I] = (char
) the malloc (the sizeof (char) *. 5);
scanf("%s",s[i]);
}

Guess you like

Origin www.cnblogs.com/gg081700/p/12047904.html