Advertisement
Guest User

Nicki detyra 4

a guest
May 29th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class alfa
  6. {
  7. private:
  8.     int a,b,c,n,x;
  9. public:
  10.     alfa()
  11.     {
  12.  
  13.     }
  14.     alfa(int a_,int b_,int c_,int x_, int n_)//Konstruktori per incializim te vlerave
  15.     {
  16.         a=a_;
  17.         b=b_;
  18.         c=c_;
  19.         x=x_;
  20.         n=n_;
  21.     }
  22.     //Deklarim i funkcioneve
  23.     int min(int a1,int b1,int c1);
  24.     int faktoriel(int n);
  25. };
  26. //Definim i funkcioneve
  27. int alfa::min(int a,int b,int c)
  28. {
  29.  if(a<b && a<c) return a;
  30.         else if(b<a && b<c) return b;
  31.         else return c;
  32. }
  33. int alfa::faktoriel(int n)
  34. {
  35.     int fakt=1;
  36.         for(int i=1;i<=n;i++)
  37.         {
  38.             fakt*=i;
  39.         }
  40.         return fakt;
  41. }
  42.  
  43. int main()
  44. {
  45.     float g;
  46.     int a,b,c,n,x;
  47.     cout<<"x = ";
  48.     cin>>x;
  49.     cout<<"n = ";
  50.     cin>>n;
  51.     cout <<"a = ";
  52.     cin>>a;
  53.     cout <<"b = ";
  54.     cin>>b;
  55.     cout <<"c = ";
  56.     cin>>c;
  57.     alfa a1(a,b,c,x,n);
  58.     g = ((3*x)/(float)a1.faktoriel(2))-(a1.faktoriel(n+1))+(3*a1.min(a,b,c));
  59.     cout << "g = "<<g;
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement