-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask8.cpp
More file actions
45 lines (36 loc) · 1.03 KB
/
task8.cpp
File metadata and controls
45 lines (36 loc) · 1.03 KB
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
#include "task8.h"
#include <cstring>
ITask::ResType Task8::Process()
{
const int N = 13;
int len = strlen(gStrNumber);
result = 0;
for(int i = 0; i < (len - N); ++i)
{
int long long summ1 = 1;
for(int j = 0; j < N; ++j)
{
if(gStrNumber[i + j] == '0')
{
break;
}
summ1 *= charToInt(gStrNumber[i + j]);
}
if(summ1 > result)
{
result = summ1;
}
}
return result;
}
std::string Task8::getDescriptionEng()
{
return std::string("Task 8\n"
"Find the thirteen adjacent digits in the 1000-digit number that have the greatest product.\n"
"What is the value of this product?\n") + std::string(gStrNumber);
}
std::string Task8::getDescriptionRus()
{
return std::string("Задача 8\n"
"Найдите наибольшее произведение тринадцати последовательных цифр в данном числе.\n") + std::string(gStrNumber);
}