Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Programming introduction / Practice-25.10.21.cpp
blob: ab966260e8f448566a0525ebfa66b35e763a532e (plain) (blame)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <iostream>

using namespace std;

/* Exercises:
 * https://github.com/triffon/ip-2021-22/blob/master/practicum/6/week3/%D0%B7%D0%B0%D0%B4%D0%B0%D1%87%D0%B8%20%D1%82%D1%80%D0%B5%D1%82%D0%B0%20%D1%81%D0%B5%D0%B4%D0%BC%D0%B8%D1%86%D0%B0.pdf
*/

void ex0() {
	int a;
	cin >> a;

	while(a != 0) {
		cout << (a % 10);
		a /= 10;
	}
	cout << endl;
}

void ex1() {
	int a;
	cin >> a;

	bool isPrime = true;
	for(int i = 2; i < a / 2; i++) { // could be improved by doing 6n +- 1 and going up to sqrt(a)
		if (a % i == 0) {
			isPrime = false;
			break;
		}
	}
	cout << ((isPrime) ? "yes" : "no") << endl;
}

void ex2() {
	int a;
	cin >> a;

	int digits = (a == 0) ? 1 : 0;
	while (a != 0) {
		digits++;
		a /= 10;
	}
	cout << digits << endl;
}

void ex3() {
	int a;
	cin >> a;

	int b;
	while(--a >= 0) {
		cin >> b;
		cout << b;
	}
	cout << endl;
}

void ex4() {
	for (int i = 100, digitSum; i < 1000; i++) { // could probably be optimized
		digitSum = i % 10 + (i / 10) % 10 + i / 100;
		if (digitSum > 9 && digitSum < 99)
			cout << i << endl;
	}
}

void ex5() {
	int n;
	cin >> n;

	if (n < 2) cout << n << endl;
	else {
		int sum = 1, current;
		for (int i = 2, j = 0; i <= n; i++, j = current) {
			current = sum;
			sum += j;
			j = current;
		}
		cout << sum << endl;
	}
}

void ex6() {
	int n;
	cin >> n;

	for(int i = 1; i <= n; i++) {
		for (int j = 1; j <= i; j++)
			cout << "*";
		cout << endl;
	}
}

void ex7() {
	int n;
	cin >> n;
	if (n % 2 == 0) n++;

	for (int i = n, starsPerRow; i >= -1 * n; i-=2) {
		starsPerRow = (i < 0) ? i * -1 : i;

		for (int j = (n - starsPerRow) / 2; j > 0; j--)
			cout << " ";
		for (int j = starsPerRow; j > 0; j--)
			cout << "*";

		cout << endl;
	}
}

void ex8() {
	int hour1, hour2;
	cin >> hour1 >> hour2;

	if (hour2 < hour1) {
		int tmp = hour2;
		hour2 = hour1;
		hour1 = tmp;
	}
	for (int i = hour1 + 1; i < hour2; i++) {
		cout << i << endl;
		if (i % 100 == 59) i += 40;
	}
}

int main() {
	ex8();
}