Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- string row;
- for (int i=0;i<n;i++) {
- for (int j=0;j<n-i-1;j++) {
- row.append(" ");
- }
- for (int k=0;k<2*i+1;k++) {
- row.append("*");
- }
- cout << row << endl;
- row = "";
- }
- for (int i=n-2;i>=0;i--) {
- for (int j=0;j<n-i-1;j++) {
- row.append(" ");
- }
- for (int k=0;k<2*i+1;k++) {
- row.append("*");
- }
- cout << row << endl;
- row = "";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement