-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy path002 print hollow diamond pattern.cpp
66 lines (56 loc) · 1.4 KB
/
002 print hollow diamond 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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int t,r,k,i,j,x=1,temp = 1;
cin>>t;
while(t--)
{
cin>>r;
cout<<"Case #"<<x++<<":"<<"\n";
for(i=1; i<=r/2+1;i++)
{
if( i==1)
{
for(j=1;j<=r/2;j++)
cout<<" ";
cout<<"*\n";
}
else
{
for(j=1;j<=((r/2)-i+1);j++)
cout<<" ";
cout<<"*";
for(k=1;k<=temp;k++)
cout<<" ";
temp+=2;
cout<<"*\n";
}
}
temp-=2;
for(i=1; i<=r/2;i++)
{
if( i==r/2)
{
for(j=1;j<=r/2;j++)
cout<<" ";
cout<<"*\n";
}
else
{
for(j=r/2;j<=r/2+i-1;j++)
cout<<" ";
cout<<"*";
temp-=2;
for(k=temp;k>=1;k--)
cout<<" ";
//temp-=2;
cout<<"*\n";
}
}
}
return 0;
}