1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream> #include <string> int main() { std::string str = "qwe"; for (unsigned i = 0; i < str.length(); ++i) { for (unsigned j = 0; j < str.length() - i; ++j) { std::cout << std::string(str, j, i + 1) << " "; } } return 0; }
1
q w e qw we qwe