Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- int y;
- float silnia(int s)
- {
- if (s==0)
- {
- return 1;
- }
- else
- return silnia(s-1)*s;
- }
- float suma(int su)
- {
- int z=1, sum=0;
- while (z<=su)
- {
- sum=sum+z;
- z++;
- }
- //cout<<sum<<endl;
- return sum;
- }
- int main()
- {
- srand(time(NULL));
- int x = 5+ rand()%6;
- cout<<"liczba x: "<<endl;
- cout<<x<<endl;
- cout << "Podaj y: " << endl;
- cin>>y;
- if (y<=0)
- {
- cout<<"podaj poprawne y"<<endl;
- cin>>y;
- }
- float wynik;
- wynik=(silnia(x)+silnia(y))/suma(y);
- cout<<"wynik: "<<wynik;
- return 0;
- }
Add Comment
Please, Sign In to add comment