Есть код
| Код | // Рис. 2.21: fig02_21.cpp // Вычисление сложного процесса
#include<iostream>
using std::cout; using std::endl; using std::ios;
#include<windows>
int rustext(char str[]) { char buffer[1024]; CharToOem(str,buffer); cout << buffer; }
#include<iomanip>
using std::setw; using std::setiosflags; using std::setprecision;
#include<cmath>
int main() { double amount, // Сумма депозита principal = 1000.0, // инициализация principal rate = 0.05; // инициализация rate
rustext("Год "); cout << setw(21); rustext("Сумма депозита"); cout << endl;
// установка формата числа с плавающей точкой cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(2);
for (int year = 1; year <= 10; year++) { amount = principal * pow(1.0 + rate, year); cout << setw(4) << year << setw(21) << amount << endl; }
system("pause"); return 0; }
|
При компиляции получаю сообщения
| Цитата | [C++ Warning] fig02_21_vichislenie_slozhnogo_procenta.cpp(17): W8070 Function should return a value [C++ Error] fig02_21_vichislenie_slozhnogo_procenta.cpp(43): E2268 Call to undefined function 'pow' [C++ Warning] fig02_21_vichislenie_slozhnogo_procenta.cpp(49): W8004 'rate' is assigned a value that is never used [C++ Warning] fig02_21_vichislenie_slozhnogo_procenta.cpp(49): W8004 'principal' is assigned a value that is never used
|
Я так понимаю, функция pow не определена. Насколько я знаю, для ее работы нужна директива cmath. Так я ее подключил. Почему же тогда получаю ошибку? |