Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cinema
- #include <algorithm>
- #include <list>
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(0, "");
- list <int> list;
- int n, k, left = 0, right = 0;
- cout << "Введите кол-во мест в кинотеатре: ";
- cin >> n;
- cout << endl;
- cout << "Введите кол-во школьников: ";
- cin >> k;
- cout << endl;
- list.push_back(n);
- while (k > 0)
- {
- if (n % 2 == 1)
- {
- list.pop_back();
- left = n / 2;
- right = n / 2;
- list.push_front(left);
- list.push_front(right);
- n = list.back();
- //cout << endl << "if: " << left << " " << right << " " << n << endl;
- }
- else
- {
- list.pop_back();
- left = n / 2;
- right = n / 2 - 1;
- list.push_front(left);
- list.push_front(right);
- n = list.back();
- //cout << endl << "else: " << left << " " << right << " " << n << " " << endl;
- }
- k--;
- }
- if (right <= left)
- {
- cout << right << endl << left << endl;
- }
- else
- {
- cout << left << endl << right << endl;
- }
- return 0;
- }
- ------------------------------------------------------
- // train
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(0, "");
- int cupe[10] = { 0 }, n, x;
- cout << "n = ";
- cin >> n;
- cout << "x = " << endl;
- for (int i = 0; i < n; i++) {
- cin >> x;
- if (x > 0 and x < 5 or x == 53 or x == 54) {
- cupe[1]++;
- }
- else if (x > 4 and x < 9 or x == 51 or x == 52) {
- cupe[2]++;
- }
- else if (x > 8 and x < 13 or x == 49 or x == 50) {
- cupe[3]++;
- }
- else if (x > 12 and x < 17 or x == 47 or x == 48) {
- cupe[4]++;
- }
- else if (x > 16 and x < 21 or x == 45 or x == 46) {
- cupe[5]++;
- }
- else if (x > 20 and x < 25 or x == 43 or x == 44) {
- cupe[6]++;
- }
- else if (x > 24 and x < 29 or x == 41 or x == 42) {
- cupe[7]++;
- }
- else if (x > 28 and x < 33 or x == 39 or x == 40) {
- cupe[8]++;
- }
- else {
- cupe[9]++;
- }
- }
- /*
- for (int i = 1; i <= 9; i++) {
- cout << "cupe[" << i << "] = " << cupe[i] << endl;
- }
- */
- int fillCupe[10] = { 0 };
- for (int i = 1; i < 10; i++) {
- if (cupe[i] == 6) {
- fillCupe[i] = 1;
- }
- //cout << "fillCupe[" << i << "] = " << fillCupe[i] << endl;
- }
- int count = 0, max = 0, k;
- for (int i = 0; i <= n; i++) {
- k = i;
- while (fillCupe[k] == 1) {
- count++;
- k++;
- }
- if (count > max) {
- max = count;
- }
- count = 0;
- }
- cout << endl << "max = " << max << endl;
- return 0;
- }
- ---------------------------------
- // num3
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(0, "");
- int answ = 0, m, n;
- cout << "ширина(m): "; // кол-во строк
- cin >> m;
- cout << "длина(n): "; // кол-во столбцов
- cin >> n;
- cout << endl;
- if (m > 0 and n > 0) {
- if (m >= n) {
- answ = factorial(m) * n;
- }
- else {
- answ = factorial(n) * m;
- }
- cout << "Кол-во прямоугольников: " << answ << endl;
- }
- else {
- cout << "Ошибка!" << endl;
- }
- system(pause);
- return 0;
- }
- ------------------------------------
- // num2
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(0, "");
- int m, num3, num4;
- cout << "m = ";
- cin >> m;
- cout << endl;
- if (m < 3) {
- num3 = 0;
- num4 = 0;
- }
- else if (m % 3 == 1) {
- num3 = (m / 3) - 1;
- num4 = 1;
- }
- else if (m % 4 == 3) {
- num3 = (m / 4) - 1;
- num4 = 1;
- }
- cout << "num3 = " << num3 << endl;
- cout << "num4 = " << num4 << endl;
- return 0;
- }
- ----------------------------------------------
- // Spinners and others
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(0, "");
- int a, b, c, n = 0;
- cout << "a = "; // стоимость основания спиннера
- cin >> a;
- cout << "b = "; // стоимость одной лопасти
- cin >> b;
- cout << "c = "; // максимальная стоимость всего спиннера
- cin >> c;
- cout << endl;
- while (a + b * n <= c) {
- n++;
- }
- cout << "n = " << n - 1 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement