Advertisement
Chessbrain94

Drugo Pitanje (ima greska)

Jan 26th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include<iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4.  
  5. int Factorial(unsigned int i)
  6.  
  7. {
  8.  
  9. int Faktorijel1 = 1, Faktorijel2 = 1, Faktorijel3;
  10. i = i * 3;
  11. for (int e = 0; e < i; e++)
  12. {
  13. if (i + 1 % 2 == 1)
  14. {
  15. i = i*-1;
  16. }
  17. Faktorijel1 = (i-e);
  18. Faktorijel2 = Faktorijel1*Faktorijel2;
  19. Faktorijel3 = Faktorijel2 * i;
  20. }
  21.  
  22. return Faktorijel3;
  23. }
  24.  
  25.  
  26. void Suma(unsigned int A, int&B)
  27.  
  28. {
  29. B = B + A;
  30. }
  31.  
  32.  
  33. int main()
  34. {
  35. unsigned int i ;
  36.  
  37.  
  38. int a = 0, Sum = 0;
  39.  
  40.  
  41. cout << "Unesite koliko brojeva hocete da unesite: ";
  42.  
  43.  
  44. cin >> a;
  45.  
  46. for (int s = 0; s < a; s++)
  47.  
  48. {
  49. cin >> i;
  50.  
  51. if (i < 0)
  52. {
  53. i = i * -1;
  54. }
  55.  
  56.  
  57. cout << Factorial(i) << endl;
  58.  
  59. Suma(Factorial(i), Sum);
  60.  
  61. cout << Sum;
  62.  
  63. }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement