/
Vladcore
/
DZ
Обзор
Документация
Войти
/
Vladcore
/
DZ
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
DZ
38 строк
818 B
Vladcore
create DZ
14 сен 2024, 02:28
14 сен 2024, 02:28
bab957f
Код
Авторство
О чём код?
#include <iostream> using namespace std; int randomNumber(int c) { int a = c * c; if (a > 999) { return ((a - (c % 10)) / 10) % 100; } if (a > 99) return (a - (c % 10)) / 10; return 0; } int numberOfCyclic(int c) { int current = c; int count = 0; while (current != 0) { current = randomNumber(current); count++; if ((current == c) || (current == randomNumber(current))){ break; } } return count; } int main() { int totalCount = 0; for (int c = 10; c <= 99; c++) { totalCount += numberOfCyclic(c); cout << "c = " << c << " | уникальных: " << numberOfCyclic(c) << endl; } cout << "Count: " << totalCount << endl; return 0; }