Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int n,i,j;;
- cout<<"Enter number of rows\n";
- cin>>n;
- int n1=n/2+1;
- for (i=1;i<=n1;i++)
- {
- for (j=1;j<=n1-i;j++)
- {cout<<" ";}
- for (j=1;j<=2*i-1;j++)
- {cout<<"*";}
- cout<<"\n";
- }
- for (i= 1;i<=n1-1;i++)
- {
- for (j=1;j<=i;j++)
- {cout<<" ";}
- for (j=1;j<=2*(n1-i)-1;j++)
- {cout<<"*";}
- cout<<"\n";
- }
- return 0;
- }
- /*
- #include <bits/stdc++.h>
- using namespace std;
- #define FIO \
- ios_base::sync_with_stdio(false); \
- cin.tie(NULL); \
- cout.tie(NULL);
- int main()
- {
- FIO;
- int n;
- cin >> n;
- int n1 = (n + 1) / 2;
- int n2 = n1 - 1;
- int i = 1;
- while (i <= n1)
- {
- int spaces = 1;
- while (spaces <= n1 - i)
- {
- cout << " ";
- spaces++;
- }
- int stars = 1;
- while (stars <= 2 * i - 1)
- {
- cout << "*";
- stars++;
- }
- cout << endl;
- i++;
- }
- i = i - 2;
- while (i >= 1)
- {
- int spaces = 1;
- while (spaces <= n2 - i + 1)
- {
- cout << " ";
- spaces++;
- }
- int stars = 1;
- while (stars <= 2 * i - 1)
- {
- cout << "*";
- stars++;
- }
- cout << endl;
- i--;
- }
- }
- */
Add Comment
Please, Sign In to add comment