forked from sachin-nono/codingpractice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriangle Pattern.cpp
More file actions
53 lines (46 loc) · 766 Bytes
/
Triangle Pattern.cpp
File metadata and controls
53 lines (46 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<<<<<<< HEAD:TRIANGLE.CPP
#include"iostream"
using namespace std;
int main()
{
=======
/*
Triangle Pattern
for ex. for n=3, the pattern will be
1
2 3 2
3 4 5 4 3
*/
#include<iostream>
using namespace std;
int main()
{
>>>>>>> c700d35abf4555cbf59093ede5d46135a128dc5d:Triangle Pattern.cpp
int rows,i,j,k,o,l,m,n,x=0,y=1,z=1,a;
cout<<"Enter number of rows:";
cin>>rows;
for(i=1;i<=rows;i++)
{
for(j=1;j<=rows-i;j++) //for tabs
cout<<"\t";
for(k=y;k<=z;k++)
{
cout<<k<<"\t"; //left half
if(k==1)
goto lb;
}
a=z;
for(l=a-1;l>=i;l--) //right half
cout<<l<<"\t";
lb:
x++;
y++;
z+=2;
cout<<endl;
}
return 0;
<<<<<<< HEAD:TRIANGLE.CPP
}
=======
}
>>>>>>> c700d35abf4555cbf59093ede5d46135a128dc5d:Triangle Pattern.cpp