int main(void) {
	Solution solution;
	vector<string> words({"This", "is", "an", "example", "of", "text", "justification."});
	int maxWidth(16);
	for (const auto& i : solution.fullJustify(words, maxWidth)) {
		cout << i << '\n';
	}
	cout << "\nPassed\n";
	cout << '\n';
	words = {"Listen","to","many,","speak","to","a","few."};
	maxWidth = 6;
	for (const auto& i : solution.fullJustify(words, maxWidth)) {
		cout << i << '\n';
	}
	cout << "\nPassed\n";
	cout << '\n';
	words = {" "};
	maxWidth = 2;
	for (const auto& i : solution.fullJustify(words, maxWidth)) {
		cout << i << '\n';
	}
	cout << "\nPassed\n";
	cout << '\n';
	words = {"Listen","to","many,","speak","to","a","few."};
	maxWidth = 6;
	for (const auto& i : solution.fullJustify(words, maxWidth)) {
		cout << i << '\n';
	}
	cout << "\nPassed\n";
	cout << '\n';
	cout << "\nPassed All\n";
	cout << '\n';
	return 0;
}
void main()
{
	Solution s;
	vector<string> w1({ "This","is","an","example","of","text","justification." });
	print(s.fullJustify(w1, 16));
	vector<string> w2({ "" });
	print(s.fullJustify(w2, 0));
	vector<string> w3({ "a" });
	print(s.fullJustify(w3, 1));
	vector<string> w4({ "a","b","c","d","e" });
	print(s.fullJustify(w4, 1));
	print(s.fullJustify(w4, 3));
}
Example #3
0
int main()
{
	Solution s;
	std::vector<std::string> words;
	//["Here","is","an","example","of","text","justification."], 16

	words.push_back(std::string("Here"));
	words.push_back(std::string("is"));
	words.push_back(std::string("an"));
	words.push_back(std::string("example"));
	words.push_back(std::string("of"));
	words.push_back(std::string("text"));
	words.push_back(std::string("justification"));
	std::vector<std::string> ans = s.fullJustify(words, 16);

	//["a","b","c","d","e"], 1
/*
	words.push_back(std::string("a"));
	words.push_back(std::string("b"));
	words.push_back(std::string("c"));
	words.push_back(std::string("d"));
	std::vector<std::string> ans = s.fullJustify(words, 1);
*/
	//["Don't","go","around","saying","the","world","owes","you","a","living;","the","world","owes","you","nothing;","it","was","here","first."], 30	["Don't  go  around  saying  the","world  owes you a living; the ","world owes you nothing; it was","here first.                   "]	["Don't  go  around  saying  the","world  owes  you a living; the","world owes you nothing; it was","here first.                   "]	
  

	cout << "result ";
	s.Output(ans);
	return 0;
}
int main(void) {
    Solution s;
    string buff;
    while (getline(cin, buff)) {
        vector<string> words;
        int L;
        istringstream iss(buff);
        char ch;
        while (iss >> ch && ch != ']') {
            string word;
            while (iss >> ch && ch != '"');
            while (iss >> ch && ch != '"') {
                word.push_back(ch);
            }
            words.push_back(word);
        }
        iss >> ch >> L;
        vector<string> ret = s.fullJustify(words, L);
        
        cout << "[" << endl;
        for (size_t i = 0; i < ret.size(); i++) {
            cout << " \"" << ret[i] << "\"" << endl;
        }
        cout << "]" << endl;
    }
    
    return 0;
}
Example #5
0
int main()
{
    Solution s;
    vector<string> a{""};
    const auto& r = s.fullJustify(a, 0);
    std::cout<<r.size()<<std::endl;
}
Example #6
0
int main() {
  Solution sol;
  vector<string> words {"Listen","to","many,","speak","to","a","few."};
  vector<string> result = sol.fullJustify(words, 6);
  cout << "=========================" << endl;
  for (int i = 0; i < result.size(); i++) 
    cout << result[i] << "%" << endl;
}
Example #7
0
int main(int argc, char const *argv[]) {
    Solution *solution = new Solution;
    string s[] = {"What", "must", "be", "shall", "be."};
    vector<string> words(s, s + 5);
    vector<string> result = solution->fullJustify(words, 12);
    for (int i = 0; i < (int)result.size(); i++)
        printf("%s\n", result[i].c_str());
    return 0;
}
Example #8
0
int main() {
    Solution solution;
    vector<string> words{"This", "is", "a", "justification.",  "example", "of", "text", "justification."};
    // vector<string> words{""};
    for (auto &a: solution.fullJustify(words, 16)) {
        cout << a << endl;
    }

	return 0;
}
Example #9
0
int main(){
	Solution c;
	string s[] = {"This", "is", "an", "example", "of", "text", "justification."};
	vector<string > words;
	for(int i = 0; i < 7; ++i) words.push_back(s[i]);
	vector<string > ans = c.fullJustify(words, 16);
	for(int i = 0; i < ans.size(); ++i)
		cout << ans[i] << endl;
	return 0;
}
int main() {
	Solution s;
	string A[] = {"Here","is","an","example","of","text","justification."};
	vector<string> v(A, A+7);
	s.fullJustify(v, 15);
//	string A[] = {"What","must","be","shall","be."};
//	vector<string> v(A, A+5);
//	s.fullJustify(v, 12);
	return 0;	
}
void test_text_justification() {
    vector<string> input;
    input.push_back(string("a"));
    input.push_back("b");
    input.push_back("c");
    input.push_back("d");
    input.push_back("e");
    
    Solution s;
    s.fullJustify(input, 3);
}
int main(void){
	Solution answer;
	string a[] = { "This", "is", "an", "example", "of", "text", "justification." };
	vector<string>ans;
	for (size_t i = 0; i < 7; ++i)
		ans.push_back(a[i]);
	vector<string>ret = answer.fullJustify(ans, 16);
	for (size_t i = 0; i < ret.size(); ++i)
		cout << ret[i] << endl;
	system("Pause");
	return 0;
}
Example #13
0
int main(int argc, int** argv){
	char *p[] = { "a", "b", "c" };
	vector<string> words;
	for (int i = 0; i < sizeof(p) / sizeof(char*); ++i)
		words.push_back(p[i]);

	Solution s;
	vector<string> vJfiedString = s.fullJustify(words, 3);

	printContainer<vector<string>>(vJfiedString, vJfiedString.size(), "", true);
	return 0;
}
Example #14
0
int main(int argc, char* argv[])
{
    vector<string> array = {"Don't","go","around","saying","the","world","owes","you","a","living;",
                            "the","world","owes","you","nothing;","it","was","here","first."};
    Solution s;
    vector<string>&& result = s.fullJustify(array, 30);
    for (auto str : result)
    {
        printf("%s\n", str.c_str());
    }
    return 0;
}
Example #15
0
int main(){
	// vector<string> words = {"This", "is", "an", "example", "of", "text", "justification."};
	// Solution sol;
	// vector<string> formatted = sol.fullJustify(words, 16);
	// vector<string> words = {"This", "is", "an", "example", "of", "text", "justification."};
	// Solution sol;
	// vector<string> formatted = sol.fullJustify(words, 14);
	vector<string> words = {"justification."};
	Solution sol;
	vector<string> formatted = sol.fullJustify(words, 14);
	
	for(auto &x: formatted) cout << x << '\n';
}
Example #16
0
int main(){
  Solution s;
  //string arr[] = {"This", "is", "an", "example", "of", "text", "justification."};
  string arr[] = {"Imagination","is","more","important","than","knowledge."};
  vector<string> words;
  for(int i = 0; i < sizeof(arr)/sizeof(string);++i)
    words.push_back(arr[i]);
  vector<string> res = s.fullJustify(words,11);
  for(int i = 0; i < res.size(); ++i)
    cout << res[i] << endl;
  getchar();
  return 0;
}
Example #17
0
int main()
{
	Solution s;
	vector<string> words = { "Don't", "go", "around", "saying", "the", "world", "owes", "you", "a", "living;", "the", "world", "owes", "you", "nothing;", "it", "was", "here", "first."};
	vector<string> ret = s.fullJustify(words , 30);

	for (unsigned i = 0; i < ret.size(); ++i)
	{
		cout << ret[i] << endl;
	}//for
	system("pause");
	return 0;
}
Example #18
0
int main() {
    Solution s;
    string ss;
    vector<string> sss;
    while (cin >> ss) {
        sss.push_back(ss);
    }
    vector<string> r = s.fullJustify(sss, 16);
    for (int i = 0; i < r.size(); ++i) {
        cout << r[i] << endl;
    }
    return 0;
}
Example #19
0
int main() {
    // Start typing your code here...
    cout << "Hello world!" << endl;
    Solution s;
    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("justification");
    int l = 16;
    vector<string> ans = s.fullJustify(words, l);
    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}
int main() {
  Solution sol;
  vector<string> words;
  words.push_back("Here");
  words.push_back("is");
  words.push_back("an");
  words.push_back("example");
  words.push_back("of");
  words.push_back("text");
  words.push_back("justification.");
  sol.fullJustify(words, 16);
  return 0;
}
Example #21
0
int main() {
    int n, l;
    cin >> n >> l;
    vector<string> w(n);
    for (auto &i : w)
        cin >> i;
    Solution s;
    vector<string> ans = s.fullJustify(w, l);
    for (auto &i : ans)
        cout << i << endl;

    return 0;
}
int main(){
    vector<string> vec; // declaration
    const char *input[] = {"This", "is", "an","example", "of", "text", "justification." };
    for(int i = 0 ; i < 7; i++){
        vec.push_back(input[i]);
    }
    Solution sol;
    vector<string> vecc = sol.fullJustify(vec,16);
    sol.printVec(vecc);
    
    // your code goes here
    return 0;
}
Example #23
0
int main(){
	//string rawStrs[] = { "This", "is", "an", "example", "of", "text", "justification." };
	string rawStrs[] = { "What", "must", "be", "shall", "be." };
	vector<string> strs = vector<string>();
	for (int i = 0; i < 5; ++i){
		strs.push_back(rawStrs[i]);
	}
	Solution s;
	auto result = s.fullJustify(strs, 12);
	for (int i = 0; i < result.size(); ++i){
		cout << result[i] << "#" << endl;
	}
	return 0;
}
Example #24
0
int main()
{
    Solution sln;
    string words[]= {"This", "is", "an", "example", "of", "text", "justification."};
    //string words[]= {"a", "b", "c", "d"};
    //string words[]= {""};
    vector<string> v(words, words + sizeof(words)/sizeof(string));
    vector<string> ret = sln.fullJustify(v, 16);
    for(int i=0; i<ret.size(); i++) {
        cout << ret[i] << endl;
    }
    system("pause");
    return 0;
}
int main() {
    Solution soln;

    vector<string> words {"This", "is", "an", "example", "of", "text", "justification."};
    // vector<string> words {"tushar", "roy", "likes", "to", "code"};

    int maxWidth = 16;
    vector<string> lines = soln.fullJustify(words, maxWidth);
    
    for (auto line: lines) {
        cout << line << endl;
    }
    
    return 0;
}
Example #26
0
int main(int argc, char** argv) {
    Solution solver;
    const char* strs[] = {
        "a","b","c","d","e"
    };
    int JustfyLength = 3;

    vector<string> words(sizeof(strs)/sizeof(char*));
    for (int i=0; i<words.size(); ++i) {
        words[i] = strs[i];
    }
    vector<string> fmwords = solver.fullJustify(words, JustfyLength);

    return 0;
}
int main(int argc, const char * argv[]) {
    auto test = [](std::initializer_list<std::string> ls, int width, std::vector<std::string> expected) {
        Solution solution;
        std::vector<std::string> words(ls);
        auto result = solution.fullJustify(words, width);
        std::cout << "[";
        std::copy(result.begin(), result.end(), std::ostream_iterator<std::string>(std::cout, ", "));
        std::cout << "]" << std::endl;
        return result == expected;
    };
    
    assert(test({"This", "is", "an", "example", "of", "text", "justification."}, 16,
         {"This    is    an", "example  of text", "justification.  "}));
    
    return 0;
}
int main(int argc, char const *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.");
    Solution sol;
    vector<string> result =sol.fullJustify(words,16);
    for(int i=0;i<result.size();i++)
        cout<<result[i]<<endl;
    return 0;
}
Example #29
0
int main()
{
	Solution s;
	string a[] = {"Don't","go","around","saying","the","world","owes","you","a","living;","the","world","owes","you","nothing;","it","was","here","first."};
	vector<string> tmp(a,a + 19);
	for(auto i: s.fullJustify(tmp, 30))
	{
		for (int j = 0; j < 30; ++j)
		{
			cout<<"-";
		}
		cout<<endl;
		cout<<i<<"|"<<endl;
	}
	return 0;
}
Example #30
0
int main() {
    Solution slt;
    vector<string> ws;
    int l;
    string w;
    cin >> l;
    while ((cin >> w) && ("-1"!=w)) {
        ws.push_back(w);
    }
    vector<string> ans = slt.fullJustify(ws, l);
    for (string str: ans) {
        cout << str << endl;
    }

    return 0;
}