Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class Factorial
  4. {
  5. private:
  6. int N;
  7. int rez;
  8. public:
  9. Factorial()
  10. {
  11. cin >> N;
  12. rez = 1;
  13. }
  14. int get_N()
  15. {
  16. return N;
  17. }
  18. int get_rez()
  19. {
  20. return rez;
  21. }
  22. int64_t factor(int N)
  23. {
  24. for (int i = 1; i <= N; i++)
  25. {
  26. rez = rez * i;
  27. }
  28. return rez;
  29. }
  30.  
  31. };
  32. int main()
  33. {
  34. int buf1;
  35. setlocale(LC_ALL, "Russian");
  36. cout << "Найдите факториал числа " << endl;
  37. cout << " Введите число " << endl;
  38. Factorial examp;
  39. buf1 = examp.get_N();
  40. cout << "Факториал равен " << examp.factor(buf1);
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement