KITEPATTERN -Editorial

PROBLEM LINK:

Practice
Contest

Author: rocknot
Tester: yogesh_5326
Editorialist:rocknot

DIFFICULTY:

EASY

PREREQUISITES:

Implementation

PROBLEM:

Yash is very fond of flying kites and today is kite flying competition in their village. Yash wants to take participate in this competition but there are some rules for this competition. Anyone who wants to participate in this competition should have a unique card with a design of kite printed on it. Most of the card’s he had were already used by some one so he cannot use them. Yash wants to participate in this competition but so he decided to use his programming skills and build his own unique card.

You are given an integer N

and you need to print the kite pattern according to the pattern given below. for N

=4,

  *
  ^**
    ***
  ^ ^****
      *****
  ^ ^****
    ***
  ^**
  *

HINT:

Observe the right angle triangle/odd or even places.

SOLUTIONS:

Solution
#include <iostream> 
using namespace std;
int main(){
int T;
cin>>T;
while(T--){
    int N,inc=0;
    cin>>N;
    for(int i=0;i<=N;i++){
        for(int j=0;j<inc;j++){
            if(i%2!=0&&j%2==0){
                cout<<"^";
            }else{
                cout<<" ";
            }
        }
        for(int j=0;j<=i;j++){
            cout<<"*";
        }
        cout<<endl;
        inc++;
    }
    inc-=2;
    for(int i=N;i>=0;i--,inc--){
        for(int j=0;j<inc;j++){
            if(i%2==0&&j%2==0){
                cout<<"^";
            }else{
                cout<<" ";
            }
        }
        for(int j=0;j<i;j++){
            cout<<"*";
        }
        if(i==0){
            
        }else{
            cout<<endl;
        }
    }
}
return 0;

}