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