fork download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. int main() {
  5. double x=2, y, p, pogr;
  6. double count=1, befy=0;
  7. double n=0;
  8. while (true) {
  9. p=pow(-1,n)*pow(x,n)/fact(n);
  10. n++;
  11. cout <<"\t" <<p;
  12. }
  13. return 0;
  14. }
  15. double fact(int N)
  16. {
  17. if(N < 0) // если пользователь ввел отрицательное число
  18. return 0; // возвращаем ноль
  19. if (N == 0) // если пользователь ввел ноль,
  20. return 1; // возвращаем факториал от нуля - не удивляетесь, но это 1 =)
  21. else // Во всех остальных случаях
  22. return N * fact(N - 1); // делаем рекурсию.
  23. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:9:29: error: ‘fact’ was not declared in this scope
  p=pow(-1,n)*pow(x,n)/fact(n);
                             ^
stdout
Standard output is empty