WA for a half day.
Like the following possible error:
Whether the end of each line is a direct line break without extra space (try n = 17)
With 62/max_length instead of 60.
Do not understand why someone tle,re is to write their own sort of too slag? Then why bothered have to write their own sort
The output of this transpose really tangled up with me for a long time, especially those that should not play the space.
Line I, the string in column J is I+j*y (Y is the number of rows that should eventually be output) (array from 0~n-1)
1#include <cstdio>2#include <algorithm>3#include <iostream>4#include <cstring>5 using namespacestd;6 7 stringa[ $];8 9 intMainvoid)Ten { One intN, M; A intx, y; - intMAXN; - intp =0; the while(cin>>N) { -printf"------------------------------------------------------------\ n"); - for(inti =0; I < n; ++i) cin>>A[i]; -Sort (A, A +n); +MAXN =0; - for(inti =0; I < n; ++i) + if(Maxn <a[i].length ()) AMAXN =a[i].length (); atx = +/(maxn+2); -y = n/x; - if(n% x) y++; - for(inti =0; i < Y; ++i) { - for(intj =0; J < X; ++j) { -m = i+j*y; in if(M >= N) Break; - Else{ tocout<<A[m]; + if(M + Y <N) - for(intK =0; K < maxn+2-a[m].length (); ++K) cout<<' '; the } * } $cout<<Endl;Panax Notoginseng } - } the return 0; +}
hoj-1011/poj-1589