Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "RUS");
- int A, N, M, Result1 = 1, Result2 = 1, Difference, Num;
- bool isIncorrect;
- cout << "Данная программа вычисляет число размещений из N по M." << endl;
- cout << "Введите целые числа N и M, где N > M:" << endl;
- do {
- isIncorrect = false;
- cin >> N >> M;
- if (cin.fail() || !(N > M)) {
- cin.clear();
- isIncorrect = true;
- cout << "Введите верные данные, где N > M:" << endl;
- while (cin.get() != '\n');
- }
- } while (isIncorrect);
- for (Num = 1; Num <= N; Num++) {
- Result1 *= Num;
- }
- Difference = N - M;
- for (Num = 1; Num <= Difference; Num++) {
- Result2 *= Num;
- }
- A = Result1 / Result2;
- cout << "Число размещений из N по M:" << A << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement