Romasmi / cpp-practice

0 stars 0 forks source link

Замечания по программе Фибоначчи #2

Closed alexey-malov closed 6 years ago

alexey-malov commented 6 years ago

https://github.com/Romasmi/cpp_oop_practice/blob/e7510c36fd92a016b0125f0872c2fed3e9acac2a/lab_1/task_3/task_3.cpp#L37-L65

Romasmi commented 6 years ago

Issue fixed by commit 1c7fd25729d3571df4ec6f972415feb75f06a462

alexey-malov commented 6 years ago

https://github.com/Romasmi/cpp_oop_practice/blob/1c7fd25729d3571df4ec6f972415feb75f06a462/lab_1/task_3/task_3.cpp#L61-L71

alexey-malov commented 6 years ago
size_t lastNumber = 0;
size_t currentNumber = 1;
size_t numbersCount = 1;

while (lastNumber < max)
{
    cout << lastNumber;

    if (numbersCount % numbersCountInLine == 0)
    {
        cout << "\n";
    }
    else
    {
        cout << " ";
    }

    if ((currentNumber + lastNumber) > numeric_limits<size_t>::max())
    {
        cout << "Next Number overflow. Program has to stop.";
        exit(1);
    }
Romasmi commented 6 years ago

Fixed by commit 2bab3f69b171e19a9fe7951641b890e915779d6d

alexey-malov commented 6 years ago
alexey-malov commented 6 years ago
0 1 1 2 3
5 8 13 21 34
55 89 144 233 377
610 987 1597 2584 4181
6765 10946 17711 28657 46368
75025 121393 196418 317811 514229
832040 1346269 2178309 3524578 5702887
9227465 14930352 24157817 39088169 63245986
102334155 165580141 267914296 433494437 701408733
1134903170 Next Number overflow. Program has to stop.can't output all numbers. P
robably, it's because of numbers overflow. Try to set not so huge MAX argument.