Hatena::Grouptopcoder

TopCoderの問題を解く

解いた問題の一覧表

2009-08-06

Justifier

| 19:16

問題文

一番長い文字列に文字列の長さを合わせる。

class Justifier {
    public:
        vector <string> justify (vector <string> textIn) {
            int longest = INT_MIN;
            for (int i = 0; i < textIn.size(); i++)
                longest = max(longest, (int)textIn[i].length());
            vector <string> result(textIn.size());
            for (int i = 0; i < textIn.size(); i++)
                result[i] = string(longest-textIn[i].length(),' ') + textIn[i];
            return result;
        }
};

NathalieadsonNathalieadson2012/07/10 00:48Unparaellled accuracy, unequivocal clarity, and undeniable importance!

qumvofqumvof2012/07/10 15:55k9l8Kn <a href="http://ffbnrpylucxq.com/">ffbnrpylucxq</a>

kxvfpogrvtkxvfpogrvt2012/07/10 21:52DUrnSr , [url=http://odqnuvepnfcs.com/]odqnuvepnfcs[/url], [link=http://gllexsagvhok.com/]gllexsagvhok[/link], http://ctntvviqpnwt.com/

ahphkwegfjvahphkwegfjv2012/07/12 12:12jHPHB5 <a href="http://wujnvnxoozdt.com/">wujnvnxoozdt</a>