#include <iostream> #include <string> #include <algorithm> using namespace std; int main() { int t, n; string s; cin >> t; while (t--) { cin >> s >> n; int len = (2 * n - 1)/2; for (int i = 0; i < len; ++i) cout << ' '; cout << s << endl; for (int i = 1; i < n-1; ++i) { for (int j = 0; j < n-i; ++j) { if (j == n - i - 1) { cout << s; int temp = 2*i-1; while (temp--) cout << ' '; cout << s << endl; break; } cout << ' '; } } if (n != 1) // ? for (int i = 0; i < (2 * n - 1); ++i) cout << s; if (t > 0) // ? cout << endl; } return 0; } |
Double click to view unformatted code.