Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Maxx = 0, i = 0;
- vector<string> s;
- string holder;
- while (getline(cin, holder))
- {
- s.push_back(holder);
- int x = holder.length();
- Maxx = max(Maxx, x);
- }
- int t = Maxx + 2;
- while (t--)
- cout << "*";
- cout << endl;
- bool flag = true;
- for (auto &i : s)
- {
- int l, r;
- if (i.length() != Maxx)
- {
- if (flag and (Maxx - i.length() - 2) % 2)
- {
- l = ((Maxx - i.length()) % 2 ? (Maxx - i.length()) / 2 + 1 : (Maxx - i.length()) / 2), r = Maxx - l - i.length();
- if (l + r != Maxx)
- flag = false;
- }
- else
- {
- r = ((Maxx - i.length()) % 2 ? (Maxx - i.length()) / 2 + 1 : (Maxx - i.length()) / 2), l = Maxx - r - i.length();
- if (l + r != Maxx)
- flag = true;
- }
- cout << "*";
- while (r--)
- cout << " ";
- cout << i;
- while (l--)
- cout << " ";
- cout << "*" << endl;
- }
- else
- {
- cout << "*" << i << "*" << endl;
- }
- }
- t = Maxx + 2;
- while (t--)
- cout << "*";
Advertisement
Add Comment
Please, Sign In to add comment