forked from VivekDubey9/Competitive-Programming-Algos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPattern.cpp
68 lines (64 loc) · 1.3 KB
/
Pattern.cpp
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
// #include <string>
#include<fstream>
using namespace std;
int pattern(int n){
int c;
cout<<"Enter 0 if you want triangle\nEnter 1 if you want reverse triangle ";
cin>>c;
if (c==0)
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < i+1; j++)
{
cout<<"*";
}
cout<<"\n";
}
}
else if (c==1)
{
for (int i = n; i > 0; i--)
{
for (int j = i; j > 0; j--)
{
cout<<"*";
}
cout<<"\n";
}
}
else
{
cout<<"Invalid Input";
return -1;
}
return 1;
}
int main(){
while (true)
{
int no_of_lines;
cout<<"Enter no of lines you want in pattern ";
cin>>no_of_lines;
if (no_of_lines>0)
{
int result=pattern(no_of_lines);
// if (result!=-1){
// break;
// }
}
else
{
cout<<"Invalid input";
}
int Choice;
cout<<"Continue printing another pattern?? -- Press any no\nExit Program -- 0 ";
cin>>Choice;
if (Choice==0){
cout<<"Thanks For Using Our Program!!!"<<endl;
break;
}
}
return 0;
}