/
githubmirror
/
CPlusPlusThings
Обзор
Документация
Войти
/
githubmirror
/
CPlusPlusThings
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
practical_exercises/10_day_practice/day2/pow.cpp
29 строк
476 B
zhangxing
support bazel complie this project and format code.
30 мар 2024, 17:00
30 мар 2024, 17:00
3c8a3f2
Код
Авторство
О чём код?
/* x的n次方.cpp */ #include <iostream> using namespace std; double power(double x, int n); int main(int argc, char const *argv[]) { int x; cin >> x; int wei = 0; int sum = 0; int each, chu; for (int i = 0; i < 8; i++) { each = x % 10; chu = x / 10; sum += each * power(2, wei); x = chu; wei++; } cout << sum << endl; return 0; } double power(double x, int n) { double val = 1.0; while (n--) { val *= x; } return val; }