Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/cpp/t01_quad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,13 @@
using namespace std;

int t01_quad() {

int N;
cin >> N;
int i = 1;
while (i*i <= N)
{
cout << i * i << " ";
i++;
}
return 0;
};
14 changes: 13 additions & 1 deletion src/main/cpp/t02_divisor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,17 @@
using namespace std;

int t02_divisor() {

int i = 2;
int N;
cin >> N;
while (i <= N)
{
if (N % i == 0)
{
cout << i;
break;
}
i++;
}
return 0;
};
24 changes: 24 additions & 0 deletions src/main/cpp/t03_twos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,29 @@
using namespace std;

int t03_twos() {
int N;
cin >> N;
int step_two = 2;

if (N == 1 | N == 2)
{
cout << "YES";
exit(0);
}

while (true)
{
step_two *= 2;
if (step_two == N)
{
cout << "YES";
break;
}
if (step_two > N)
{
cout << "NO";
break;
}
}
return 0;
};
13 changes: 12 additions & 1 deletion src/main/cpp/t04_sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,15 @@ using namespace std;

int t04_sum() {

};
int N;
cin >> N;

int sum = 0;
while (N)
{
sum += N;
cin >> N;
}
cout << sum;
return 0;
}
12 changes: 12 additions & 0 deletions src/main/cpp/t05_max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,16 @@ using namespace std;

int t05_max() {

int N;
cin >> N;
int max = 0;

while (N)
{
if (N > max) max = N;

cin >> N;
}
cout << max;
return 0;
};
18 changes: 18 additions & 0 deletions src/main/cpp/t06_max_count.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,22 @@ using namespace std;

int t06_max_count() {

int N;
cin >> N;

int max = 0;
int maxcount = 0;

while (N)
{
if (N > max)
{
max = N;
maxcount = 1;
}
else if (N == max) maxcount++;

cin >> N;
}
cout << maxcount;
};
19 changes: 19 additions & 0 deletions src/main/cpp/t07_max_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,23 @@ using namespace std;

int t07_max_2() {

int N;
cin >> N;

int max = N;
int after_max = -1;

while (N)
{
cin >> N;
if (N > max)
{
after_max = max;
max = N;
}
else if (N > after_max) after_max = N;
}

cout << after_max;
return 0;
};
24 changes: 24 additions & 0 deletions src/main/cpp/t08_fibb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,29 @@
using namespace std;

int t08_fibb() {
int N, prev;
int i = 2;
cin >> N;

int F1 = 1;
int F2 = 1;
if (N == 1 | N == 2)
{
cout << '1';
exit(0);
}

if (N)
{
while (N - i)
{
prev = F2;
F2 += F1;
F1 = prev;
i++;
}
cout << F2;
}
else cout << '0';
return 0;
};
26 changes: 26 additions & 0 deletions src/main/cpp/t09_row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,31 @@
using namespace std;

int t09_row() {
int duration = 1;
int max_duration = 1;

int N;
cin >> N;

int prev = N;

while (N)
{
cin >> N;
if (N == prev) duration++;

else if (duration > max_duration)
{
max_duration = duration;
duration = 1;
prev = N;
} else
{
duration = 1;
prev = N;
}
}

cout << max_duration;
return 0;
};
22 changes: 21 additions & 1 deletion src/main/cpp/t10_max_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,25 @@
using namespace std;

int t10_max_local() {

int prev, cur, next;
int number = 0;
cin >> prev;

if (prev)
{
cin >> cur;
if (cur)
{
cin >> next;
if (next) while (next)
{
if ((prev < cur) & (cur > next)) number++;
prev = cur;
cur = next;
cin >> next;
}
}
}
cout << number;
return 0;
};