-
Notifications
You must be signed in to change notification settings - Fork 0
/
snowmen.cpp
108 lines (91 loc) · 3.04 KB
/
snowmen.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Pawel Adamczuk
//A program printing snowmen with ASCII characters.
#include <iostream>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main()
{
int n;
int m;
cin >> n >> m;
//kapelusz - gorna czesc
for (int i = 0; i < n; i++)
{
for (int l = 0; l < m * n; l++)
cout << ' ';
for (int j = - 3 * n; j <= 3 * n; j++)
if (abs (j) <= 2 * n)
cout << '#';
else
cout << ' ';
cout << endl;
}
//kapelusz - dolna czesc
for (int i = 0; i < n; i++)
{
for (int l = 0; l < m * n; l++)
cout << ' ';
for (int j = - 3 * n; j <= 3 * n; j++)
cout << '#';
cout << endl;
}
for (int i = 2 * n; i > - 2 * n; i--) //matryca kuli glowy
if (2 * n - i >= n) //ucinamy kule glowy z gory i dolu
{
for (int l = 0; l < m * n; l++)
cout << ' ';
for (int j = - 3 * n; j <= 3 * n; j++) //rysujemy kule glowy
{
if (j == 0 and i == -n) //usta
cout << '-';
else
if (abs (j) == n / 2 + 1 and i == n / 2)
cout << 'O';
else
if (sqrt (pow (j, 2) + pow (i, 2)) <= 2 * n)
cout << '*';
else
cout << ' ';
}
cout << endl;
}
for (int i = 3 * n - 1; i > - 3 * n; i--) //tulow
{
for (int l = 0; l < m * n; l++)
cout << ' ';
for (int j = - 3 * n; j <= 3 * n; j++)
{
if (j != 0 or i != 0)
if (sqrt (pow (j, 2) + pow (i, 2)) <= 3 * n)
if (i > abs (j))
cout << '|';
else
cout << '*';
else
cout << ' ';
else
cout << 'X';
}
cout << endl;
}
for (int k = 4; k <= 3 + m; k++) //rysowanie kul
{
for (int i = k * n - 1; i > - n * k; i--)
{
for (int l = 0; l < n * (m + 3 - k); l++)
cout << ' ';
for (int j = - n * k; j <= n * k; j++)
{
if (j != 0 or i != 0)
if (sqrt (pow (j, 2) + pow (i, 2)) <= k * n)
cout << '*';
else
cout << ' ';
else
cout << 'X';
}
cout << endl;
}
}
} // main end