コード例 #1
0
ファイル: 68.c プロジェクト: Coordinate35/leetcode
int main() {
    char **words;
    int maxWidth = 14;
    int wordsSize = 7;
    int i;
    int returnSize;
    char** result;
    words = (char**)malloc(wordsSize * sizeof(char*));
    for (i = 0; i < wordsSize; i++) {
        words[i] = (char*)malloc((maxWidth + 1) * sizeof(char));
        scanf("%s", words[i]);
    }
    result = fullJustify(words, wordsSize, maxWidth, &returnSize);
    return 0;
}
コード例 #2
0
ファイル: sol1.cpp プロジェクト: wddabc/leetcode
int main(int argc, const char* argv[])
{
	vector<string> words;
	words.push_back("This");
	words.push_back("is");
	words.push_back("an");
	words.push_back("example");
	words.push_back("of");
	words.push_back("text");
	words.push_back("justification.");
	vector<string> res = fullJustify(words, 14);
	for(int i = 0; i < res.size(); ++i)
	  cout << res[i]  << "#"<< endl;
	return 0;
}
コード例 #3
0
ファイル: text-justification.cpp プロジェクト: Rand3/leetcode
	void test() {
		vector<pair<vector<string>, int>> tests = {
				{ { "this", "is", "really", "good", "ok===================================================================" }, 30 },
				// 4 + 2 + 6 + 4 = 16, + 3 space = 19, + extra 11 = 30
				{ { "This", "is", "an", "example", "of", "text", "justification." }, 16 },
				{ { "Listen", "to", "many,", "speak", "to", "a", "few." }, 6 },
				{ { "" }, 2 },
		};
		for (auto test : tests) {
			vector<string> words = test.first;
			int len = test.second;
			vector<string> result = fullJustify(words, len);
			for (string s : result) {
				cout << '[' << s << ']' << endl;
			}
			cout << endl;
		}
	}