fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. const int MAX_LENGTH = 1000;
  6. const int MAX_SIZE = 20;
  7.  
  8. void cutStars(char l[]) {
  9. int n = strlen(l);
  10. while (l[n - 1] == '*') {
  11. --n;
  12. }
  13. l[n] = 0;
  14. }
  15.  
  16. int main() {
  17. char mt[MAX_SIZE + 1][MAX_LENGTH + 1];
  18. int maxSize = 0, currentLine = 0;
  19. while (!cin.eof()) {
  20. cin.getline(mt[currentLine], MAX_LENGTH + 1);
  21. int n = strlen(mt[currentLine]);
  22. if (n > maxSize) {
  23. maxSize = n;
  24. }
  25. cutStars(mt[currentLine]);
  26. ++currentLine;
  27. }
  28. for (int j = 0; j < currentLine; ++j) {
  29. int n = strlen(mt[j]);
  30. for (int l = n; l < maxSize; ++l) {
  31. cout << "*";
  32. }
  33. cout << mt[j] << "\n";
  34. }
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5280KB
stdin
****a*****
stdout
*********a