Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. // cinema
  2.  
  3. #include <algorithm>
  4. #include <list>
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. setlocale(0, "");
  11.  
  12. list <int> list;
  13. int n, k, left = 0, right = 0;
  14.  
  15. cout << "Введите кол-во мест в кинотеатре: ";
  16. cin >> n;
  17. cout << endl;
  18.  
  19. cout << "Введите кол-во школьников: ";
  20. cin >> k;
  21. cout << endl;
  22.  
  23. list.push_back(n);
  24.  
  25. while (k > 0)
  26. {
  27. if (n % 2 == 1)
  28. {
  29. list.pop_back();
  30.  
  31. left = n / 2;
  32. right = n / 2;
  33.  
  34. list.push_front(left);
  35. list.push_front(right);
  36.  
  37. n = list.back();
  38. //cout << endl << "if: " << left << " " << right << " " << n << endl;
  39. }
  40. else
  41. {
  42. list.pop_back();
  43.  
  44. left = n / 2;
  45. right = n / 2 - 1;
  46.  
  47. list.push_front(left);
  48. list.push_front(right);
  49.  
  50. n = list.back();
  51. //cout << endl << "else: " << left << " " << right << " " << n << " " << endl;
  52. }
  53. k--;
  54. }
  55.  
  56. if (right <= left)
  57. {
  58. cout << right << endl << left << endl;
  59. }
  60. else
  61. {
  62. cout << left << endl << right << endl;
  63. }
  64.  
  65. return 0;
  66. }
  67.  
  68. ------------------------------------------------------
  69.  
  70. // train
  71.  
  72. #include <iostream>
  73. using namespace std;
  74.  
  75. int main()
  76. {
  77. setlocale(0, "");
  78.  
  79. int cupe[10] = { 0 }, n, x;
  80.  
  81. cout << "n = ";
  82. cin >> n;
  83.  
  84. cout << "x = " << endl;
  85. for (int i = 0; i < n; i++) {
  86. cin >> x;
  87. if (x > 0 and x < 5 or x == 53 or x == 54) {
  88. cupe[1]++;
  89. }
  90. else if (x > 4 and x < 9 or x == 51 or x == 52) {
  91. cupe[2]++;
  92. }
  93. else if (x > 8 and x < 13 or x == 49 or x == 50) {
  94. cupe[3]++;
  95. }
  96. else if (x > 12 and x < 17 or x == 47 or x == 48) {
  97. cupe[4]++;
  98. }
  99. else if (x > 16 and x < 21 or x == 45 or x == 46) {
  100. cupe[5]++;
  101. }
  102. else if (x > 20 and x < 25 or x == 43 or x == 44) {
  103. cupe[6]++;
  104. }
  105. else if (x > 24 and x < 29 or x == 41 or x == 42) {
  106. cupe[7]++;
  107. }
  108. else if (x > 28 and x < 33 or x == 39 or x == 40) {
  109. cupe[8]++;
  110. }
  111. else {
  112. cupe[9]++;
  113. }
  114. }
  115.  
  116. /*
  117. for (int i = 1; i <= 9; i++) {
  118. cout << "cupe[" << i << "] = " << cupe[i] << endl;
  119. }
  120. */
  121.  
  122. int fillCupe[10] = { 0 };
  123. for (int i = 1; i < 10; i++) {
  124. if (cupe[i] == 6) {
  125. fillCupe[i] = 1;
  126. }
  127. //cout << "fillCupe[" << i << "] = " << fillCupe[i] << endl;
  128. }
  129.  
  130.  
  131. int count = 0, max = 0, k;
  132. for (int i = 0; i <= n; i++) {
  133. k = i;
  134. while (fillCupe[k] == 1) {
  135. count++;
  136. k++;
  137. }
  138. if (count > max) {
  139. max = count;
  140. }
  141. count = 0;
  142. }
  143.  
  144. cout << endl << "max = " << max << endl;
  145.  
  146. return 0;
  147. }
  148.  
  149. ---------------------------------
  150.  
  151. // num3
  152.  
  153. #include <iostream>
  154. using namespace std;
  155.  
  156. int main()
  157. {
  158. setlocale(0, "");
  159.  
  160. int answ = 0, m, n;
  161. cout << "ширина(m): "; // кол-во строк
  162. cin >> m;
  163. cout << "длина(n): "; // кол-во столбцов
  164. cin >> n;
  165. cout << endl;
  166.  
  167. if (m > 0 and n > 0) {
  168. if (m >= n) {
  169. answ = factorial(m) * n;
  170. }
  171. else {
  172. answ = factorial(n) * m;
  173. }
  174.  
  175. cout << "Кол-во прямоугольников: " << answ << endl;
  176. }
  177. else {
  178. cout << "Ошибка!" << endl;
  179. }
  180. system(pause);
  181.  
  182. return 0;
  183. }
  184.  
  185. ------------------------------------
  186.  
  187. // num2
  188.  
  189. #include <iostream>
  190. using namespace std;
  191.  
  192. int main()
  193. {
  194. setlocale(0, "");
  195.  
  196. int m, num3, num4;
  197. cout << "m = ";
  198. cin >> m;
  199. cout << endl;
  200.  
  201. if (m < 3) {
  202. num3 = 0;
  203. num4 = 0;
  204. }
  205. else if (m % 3 == 1) {
  206. num3 = (m / 3) - 1;
  207. num4 = 1;
  208. }
  209. else if (m % 4 == 3) {
  210. num3 = (m / 4) - 1;
  211. num4 = 1;
  212. }
  213. cout << "num3 = " << num3 << endl;
  214. cout << "num4 = " << num4 << endl;
  215.  
  216. return 0;
  217. }
  218.  
  219. ----------------------------------------------
  220.  
  221. // Spinners and others
  222.  
  223. #include <iostream>
  224. using namespace std;
  225.  
  226. int main()
  227. {
  228. setlocale(0, "");
  229.  
  230. int a, b, c, n = 0;
  231. cout << "a = "; // стоимость основания спиннера
  232. cin >> a;
  233. cout << "b = "; // стоимость одной лопасти
  234. cin >> b;
  235. cout << "c = "; // максимальная стоимость всего спиннера
  236. cin >> c;
  237. cout << endl;
  238.  
  239. while (a + b * n <= c) {
  240. n++;
  241. }
  242.  
  243. cout << "n = " << n - 1 << endl;
  244.  
  245. return 0;
  246. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement