Thursday, 6 April 2017

Geeksforgeeks Solution For " Print Pattern "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Print Pattern

Submit Your Solution :- Click Here 

Solution :- 

#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--)
{
   int n,flag=0;
   cin>>n;
   int i=n-5;
   cout<<n<<" "<<i<<" " ;
while(i!=n)
{
    if(i>0&&flag==0)
    i-=5;
    else {i+=5;
    flag=1;}
    cout<<i<<" ";
}
cout<<endl;
}
return 0;
}

Output:-



Geeksforgeeks Solution For " Print Pattern "

No comments:
Write comments

Recommended Posts × +