Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<conio.h>
- using namespace std;
- int fac(int a){
- int b = 1;
- for (int i = 1; i <= a; i++)
- b *= i;
- return b;
- }
- int razA(int m, int n){
- int r = (fac(n)) / fac((n - m));
- return r;
- }
- int razB(int m, int n){
- int r=n;
- for (int i = 1; i <= m-1; i++){
- r *= n;
- }
- return r;
- }
- int per(int n, int m) {
- int n1;
- int n2;
- int down = 1;
- for (int i = 1; i <= m; i++){
- cout << "Vvedite N" << i << " element: ";
- cin >> n1;
- down *= fac(n1);
- }
- int r = fac(n) / down;
- return r;
- }
- int socA(int m, int n){
- int r = (fac(n)) / (fac(m)*(fac(n - m)));
- return r;
- }
- int socB(int m, int n){
- int r = socA(m, n + m - 1);
- return r;
- }
- int main(){
- int result=0;
- int m, n;
- cout << endl<<"Choose type: \n1=r\n2=p\n3=s ";
- int choose1,choose2;
- cin >> choose1;
- switch (choose1){
- case 1:
- cout << endl<<"Choose s povtorami or not 1/2 ";
- cin >> choose2;
- switch (choose2){
- case 1:
- cout << endl<<"Type m and n cherez probel: ";
- cin >> m >> n;
- result = razA(m, n);
- break;
- case 2:
- cout << endl<<"Type m and n cherez probel: ";
- cin >> m >> n;
- result = razB(m, n);
- break;
- }
- break;
- case 2:
- cout << endl<<"Choose s povtorami or not 1/2 ";
- cin >> choose2;
- switch (choose2){
- case 1:
- cout << endl<<"Type n: ";
- cin >> n;
- result = fac(n);
- break;
- case 2:
- cout << endl<<"Vvedite n: ";
- cin >> n;
- cout << endl<<"Vvedite kol-vo Nn: ";
- cin >> m;
- result = per(n, m);
- }
- break;
- case 3:
- cout << endl<<"Choose s povtorami or not 1/2 ";
- cin >> choose2;
- switch (choose2){
- case 1:
- cout << endl<<"Type m and n cherez probel: ";
- cin >> m >> n;
- result = socA(m, n);
- break;
- case 2:
- cout << endl<<"Type m and n cherez probel: ";
- cin >> m >> n;
- result = socB(m, n);
- break;
- }
- break;
- }
- cout << "\nResult is: " << result;
- cout << "\nPress anykey for exit";
- char ak;
- ak = _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement