Number Star Pattern

 Number Star Pattern in C++

Input format :

Line 1 : N (Total number of rows)

Sample Input :
   5
Sample Output :
1234554321
1234**4321
123****321
12******21
1********1
C++ Code:
#include<iostream>
using namespace std;

int main(){

  int n;
  cin>>n;
  for(int i=1; i<=n; i++)
  {
   for(int j=1; j<=n-i+1; j++)
    {
      cout<<j;
    }
    for(int j=i;j>1;j--)
    {
    	cout<<"*";
	}
	for(int j=2;j<=i;j++)
    {
    	cout<<"*";
	}
    for(int j=n+1-i; j>0; j--)
    {
      cout<<j;
    }
    cout<<endl;
  }

  
}




SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment