-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpattern12.cpp
27 lines (27 loc) · 1.08 KB
/
pattern12.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
#include <iostream>
using namespace std;
int main(){
int n,i,j;
cout<<"Enter number of lines: ";
cin>>n; // Enter number of lines
cout<<"The pattern is:\n"; //*
for(i=1;i<=n;i++){ //**
if((i==1)||(i==n)){ //* *
for(j=1;j<=i;j++){ //* *
cout<<"*"; //* *
} //******
} // Star Pattern
else{ // 'i' is used for rows
for(j=1;j<=i;j++){ // 'j' is used for columns
if((j==1)||(j==i)){
cout<<"*";
}
else{
cout<<" ";
}
}
}
cout<<endl;
}
return 0;
}