Polnochniy

Untitled

Feb 10th, 2020
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 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. void set_N(int buf)
  10. {
  11. N = buf;
  12. }
  13. int get_N()
  14. {
  15. return N;
  16. }
  17. void set_rez(int buf2)
  18. {
  19. rez = buf2;
  20. }
  21. int get_rez()
  22. {
  23. return rez;
  24. }
  25. int64_t factor(int N)
  26. {
  27. for (int i = 1; i <= N; i++)
  28. {
  29. rez = rez * i;
  30. }
  31. return rez;
  32. }
  33.  
  34. };
  35. int main()
  36. {
  37. int buf ,buf2 ,buf3;
  38. buf2 = 1;
  39. setlocale(LC_ALL, "Russian");
  40. cout << " Введите число " << endl;
  41. cin >> buf;
  42. Factorial examp;
  43. examp.set_N(buf);
  44. examp.set_rez(buf2);
  45. buf3 = examp.get_N();
  46. cout << "Факториал равен " << examp.factor(buf3);
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment