Не работает код с++ - Вопросы по С+

Вопрос Не работает код с++

Регистрация
29 Дек 2013
Сообщения
94
Репутация
0
Спасибо
0
Монет
0
308023460_92278bed7de9085a3a40c803c98d267f_800.png

#include <iostream>



using namespace std;



int main() {



long long a = pow(49, 6) + pow(7, 19) - 21;

int k = 0;

while (a > 0) {

if (a % 7 == 0) {

k++;

}

a = a / 7;

}

cout << k;





return 0;

}
 
Регистрация
27 Окт 2012
Сообщения
97
Репутация
0
Спасибо
1
Монет
0
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

string convert_base(long long number, const int base) {
const char digits[] = "0123456789ABCDEF";
string box;
while (number) {
box = digits[number % base] + box;
number /= base;
}
return box;
}

long long power(const int num, const int base) {
auto result = 1LL;
for (auto i = 0; i < base; ++i) result *= num;
return result;
}

int main() {
const auto a = power(49, 6) + power(7, 19) - 21;
cout << "Base10: " << a << '\n';
const auto b = convert_base(a, 7);
cout << "Base7: " << b << '\n';
const auto n = count(begin(b), end(b), '0');
cout << "Number of zeros: " << n << '\n';
}
 
Сверху Снизу