-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathx-shape.cpp
More file actions
34 lines (34 loc) · 786 Bytes
/
x-shape.cpp
File metadata and controls
34 lines (34 loc) · 786 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
#include <iostream>
using namespace std;
main(){
int n,i,j;
cin>>n;
for(i=1;i<=n;i++){
for(j=1;j<i;j++){
cout<<" ";
}
cout<<"*";
for(j=(2*(n-i))-1;j>=1;j--){
cout<<" ";
}
if(i!=n){
cout<<"*";
}
else{ //* *
cout<<" "; // * *
} // * *
cout<<endl; // * *
} // * *
for(i=2;i<=n;i++){ // *
for(j=(n-i);j>=1;j--){ // * *
cout<<" "; // * *
} // * *
cout<<"*"; // * *
for(j=1;j<=((2*i)-3);j++){ //* *
cout<<" "; //Star pattern problem
}
cout<<"*";
cout<<endl;
}
return 0;
}