Initial commit

This commit is contained in:
2022-06-01 20:14:50 +03:00
commit 8b9cce4739
1094 changed files with 68851 additions and 0 deletions

53
2022/sector/code/code.cpp Normal file
View File

@@ -0,0 +1,53 @@
#include <iostream>
#include <fstream>
using namespace std;
ifstream input_stream;
ofstream output_stream;
uint16_t generateNumber(uint16_t first, uint16_t second, uint16_t third, uint16_t fourth) {
return first * 1000 + second * 100 + third * 10 + fourth;
}
int main() {
input_stream.open("input.txt");
output_stream.open("output.txt");
uint16_t first, third;
// File method:
// input_stream >> first;
// input_stream >> third;
// Console method:
cin >> first;
cin >> third;
uint16_t total = 0;
for (uint16_t second = 0; second <= 9; second++) {
for (uint16_t fourth = 0; fourth <= 9; fourth++) {
uint16_t generatedNumber = generateNumber(first, second, third, fourth);
if (generatedNumber % 9 == 0) {
// File method:
// output_stream << generatedNumber << endl;
// Console method:
cout << generatedNumber << endl;
total++;
}
}
}
// File method:
// output_stream << total << endl;
// Console method:
cout << total << endl;
input_stream.close();
output_stream.close();
return 0;
}

View File

@@ -0,0 +1,73 @@
#include <iostream>
#include <fstream>
using namespace std;
ifstream input_stream;
ofstream output_stream;
void runMarkdown(bool mx[][100], bool mk[][100], uint16_t nodeX, uint16_t nodeY, uint8_t N) {
mk[nodeY][nodeX] = true;
// Top
if (nodeY - 1 >= 0 && mx[nodeY - 1][nodeX] && !mk[nodeY - 1][nodeX]) {
runMarkdown(mx, mk, nodeX, nodeY - 1, N);
}
// Bottom
if (nodeY + 1 < N && mx[nodeY + 1][nodeX] && !mk[nodeY + 1][nodeX]) {
runMarkdown(mx, mk, nodeX, nodeY + 1, N);
}
// Left
if (nodeX - 1 >= 0 && mx[nodeY][nodeX - 1] && !mk[nodeY][nodeX - 1]) {
runMarkdown(mx, mk, nodeX - 1, nodeY, N);
}
// Right
if (nodeX + 1 < N && mx[nodeY][nodeX + 1] && !mk[nodeY][nodeX + 1]) {
runMarkdown(mx, mk, nodeX + 1, nodeY, N);
}
}
int main() {
input_stream.open("Insule.txt");
output_stream.open("output.txt");
uint16_t N;
input_stream >> N;
bool matrix[N][100];
bool marks[N][100];
for (uint8_t i = 0; i < N; i++) {
for (uint8_t j = 0; j < N; j++) {
input_stream >> matrix[i][j];
marks[i][j] = 0;
}
}
uint32_t total = 0;
for (uint16_t i = 0; i < N; i++) {
for (uint16_t j = 0; j < N; j++) {
if (matrix[i][j] && !marks[i][j]) {
runMarkdown(matrix, marks, j, i, N);
total++;
}
}
}
// File method:
// output_stream << total << endl;
// Console method:
cout << total << endl;
input_stream.close();
return 0;
}

View File

@@ -0,0 +1,7 @@
6
0 1 0 1 1 0
1 1 0 0 1 1
0 0 0 0 0 1
1 0 1 0 0 0
1 1 1 1 0 0
0 0 0 0 1 1

View File

@@ -0,0 +1,10 @@
4
1 1 1 1
1 1 0 0
0 0 1 1
1 0 1 1

View File

@@ -0,0 +1,4 @@
3
1 0 1
0 0 0
1 0 1

View File

@@ -0,0 +1,8 @@
7
0 0 0 0 0 0 0
0 0 1 1 0 0 1
1 1 1 0 0 1 1
0 0 0 1 0 0 0
1 0 0 1 0 0 0
1 1 0 0 1 1 1
0 1 0 0 1 0 0

View File

@@ -0,0 +1,6 @@
5
0 0 1 0 0
0 0 1 0 0
1 1 1 1 1
0 1 0 0 0
0 1 0 0 0

View File

@@ -0,0 +1,5 @@
4
1 1 1 1
0 1 0 0
0 0 0 1
0 0 1 1

View File

@@ -0,0 +1,8 @@
6
1 1 0 1 1 0
1 1 0 0 1 1
0 0 0 1 1 1
1 0 1 0 0 0
1 0 1 1 1 0
1 1 1 0 1 1

View File

@@ -0,0 +1,6 @@
3
0 0 0
0 0 0
0 0 0

View File

@@ -0,0 +1,11 @@
7
0 0 1 1 0 1 0
0 0 1 1 0 1 1
1 1 1 1 0 1 1
0 1 0 1 0 0 0
1 1 0 1 1 0 0
1 1 0 0 1 1 1
0 1 0 0 1 0 0

View File

@@ -0,0 +1,10 @@
5
0 0 1 0 1
0 1 1 1 0
1 1 0 1 1
0 1 0 1 1
0 1 1 1 1

View File

@@ -0,0 +1,75 @@
#include <iostream>
#include <fstream>
using namespace std;
ifstream input_stream;
ofstream output_stream;
bool is_palindrome(string s) {
uint8_t s_len = s.length();
for (uint8_t i = 0; i < (s_len / 2); i++) {
if (s[i] != s[s_len - i - 1]) {
return false;
}
}
return true;
}
int main() {
input_stream.open("input.txt");
output_stream.open("output.txt");
string max_pal, tmp;
string inp = "";
// File method:
while (true) {
input_stream >> tmp;
if (tmp == "") {
break;
}
inp += " " + tmp;
tmp = "";
}
uint8_t max_pal_len = 0;
uint8_t inp_len = inp.length();
for (uint8_t i = 0; i < (inp_len - 1); i++) {
for (uint8_t j = inp_len - i; j >= 2; j--) {
if (j > max_pal_len) {
string sub = inp.substr(i, j);
if (is_palindrome(sub)) {
max_pal_len = j;
max_pal = sub;
}
}
}
}
// File method:
// if (max_pal_len == 0) {
// output_stream << "Nu se contine" << endl;
// } else {
// output_stream << max_pal << endl;
// }
// Console method:
if (max_pal_len == 0) {
cout << "Nu se contine" << endl;
} else {
cout << max_pal << endl;
}
input_stream.close();
output_stream.close();
return 0;
}

View File

@@ -0,0 +1 @@
apacojoc

View File

@@ -0,0 +1 @@
iepurasulusarupe

View File

@@ -0,0 +1 @@
initial

View File

@@ -0,0 +1 @@
port

View File

@@ -0,0 +1 @@
niciunuicinueste

View File

@@ -0,0 +1 @@
caracteristici

View File

@@ -0,0 +1 @@
101101

View File

@@ -0,0 +1 @@
d

View File

@@ -0,0 +1 @@
nimeni nu cunoaste totul

View File

@@ -0,0 +1 @@
abcdefghgfedcabra