#include "stdlib.h" #include "algorithm" #include "iostream" #include <cstdio> #include "string" #include <iomanip> #include <map> #include <set> #include "math.h" using namespace std; map<int, bool> mp; set<string> st; void P(int n) { for (int i = 1; i <= n; i++) { for (int j = n - i; j > 0; j--)cout << " "; for (int k = 2 * i - 1; k > 0; k--)cout << "*"; cout << endl; } for (int i = n - 1; i > 0; i--) { for (int j = n - i; j > 0; j--)cout << " "; for (int k = 2 * i - 1; k > 0; k--)cout << "*"; cout << endl; } } int main() { int n; cin >> n; P(n); return 0; } |
Double click to view unformatted code.