Advertisement
Guest User

Untitled

a guest
Jan 8th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. // ConsoleApplication25.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <cstdlib>
  7.  
  8. using namespace std;
  9.  
  10. int silnia(int a)
  11. {
  12. int tab[100];
  13. int x = 2;
  14. int c = a;
  15. tab[0] = a;
  16. tab[1] = a*(a - 1);
  17.  
  18. if (a == 0)
  19. {
  20. return 1;
  21. }
  22.  
  23. if(x<c)
  24. {
  25. tab[x] = tab[x - 1] * tab[x - 2];
  26. x++;
  27. }
  28.  
  29.  
  30. cout << endl << tab[x] << "/t";
  31. return a*silnia(a - 1);
  32. }
  33.  
  34. bool parzysta(int a)
  35. {
  36. if (a % 2 == 0)
  37. {
  38. cout << "liczba jest parzysta" << endl;
  39. return true;
  40. }
  41. else
  42. {
  43. cout << "liczba nieparzysta" << endl;
  44. return false;
  45. }
  46. }
  47.  
  48. int main()
  49. {
  50. int a;
  51. cout << "podaj a mniejsze od 100: " << endl;
  52. cin >> a;
  53. if (a >= 100){
  54. cout << "podaj a mniejsze od 100!" << endl;
  55. cin >> a;
  56. }
  57. parzysta(a);
  58. cout << endl<< silnia(a) << endl;
  59.  
  60.  
  61. system("pause");
  62.  
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement