|
4 / 4 / 0
Регистрация: 23.01.2020
Сообщений: 34
|
|
Перевод кода с c++ на python22.12.2021, 18:11. Показов 1687. Ответов 0
Метки нет (Все метки)
#include <iostream>
#include <vector> using namespace std; void input_plural(int* plural, int n); void output_plural(int* plural, int n); void multiplication_plural(int* plural1, int n_1, int* plural2, int n_2, int* p_result, int n_result); void addition_plural(int* plural1, int n_1, int* plural2, int n_2, int* p_result, int n_result); void substraction_plural(int* plural1, int & n_1, int* plural2, int n_2); int main() { setlocale(LC_ALL, "ru"); cout << "Введiть потужнiсть множини А: "; int n_a; cin >> n_a; int* a = new int[n_a]; cout << "Введiть значення елементiв множини А:" << endl; input_plural(a, n_a); cout << endl; cout << "Множина А" << endl; output_plural(a, n_a); cout << endl; cout << "Введiть потужнiсть множини B: "; int n_b; cin >> n_b; int* b = new int[n_b]; cout << "Введiть значення елементiв множини B:" << endl; input_plural(b, n_b); cout << endl; cout << "Множина B" << endl; output_plural(b, n_b); cout << endl; cout << "Введiть потужнiсть множини C: "; int n_c; cin >> n_c; int* c = new int[n_c]; cout << "Введiть значення елементiв множини C:" << endl; input_plural(c, n_c); cout << endl; cout << "Множина C" << endl; output_plural(c, n_c); cout << endl; cout << "Введiть потужнiсть множини D: "; int n_d; cin >> n_d; int* d = new int[n_d]; cout << "Введiть значення елементiв множини D:" << endl; input_plural(d, n_d); cout << endl; cout << "Множина D" << endl; output_plural(d, n_d); cout << endl; cout << "F = (A + B * C - D) * D = " << endl; cout << "A * B:" << endl; int* p_mul_result = new int[n_a * n_b]; int n_mul_result = n_a * n_b; multiplication_plural(a, n_a, b, n_b, p_mul_result, n_mul_result); output_plural(p_mul_result, n_mul_result); cout << endl; cout << "A + B:" << endl; int* p_add_result = new int[n_a + n_b]; int n_add_result = n_a + n_b; addition_plural(a, n_a, b, n_b, p_add_result, n_add_result); output_plural(p_add_result, n_add_result); cout << endl; cout << "A - B:" << endl; substraction_plural(a, n_a, b, n_b); output_plural(a, n_a); cout << endl; return 0; } void input_plural(int* plural, int n) { for (int i = 0; i < n; i++) { cin >> plural[i]; } } void output_plural(int* plural, int n) { for (int i = 0; i < n; i++) { cout << plural[i] << " "; } cout << endl; } void multiplication_plural(int* plural1, int n_1, int* plural2, int n_2, int* p_result, int n_result) { int k = 0; for (int i = 0; i < n_1; i++) { for (int j = 0; j < n_2; j++) { p_result[k] = plural1[i] * plural2[j]; k++; } } } void addition_plural(int* plural1, int n_1, int* plural2, int n_2, int* p_result, int n_result) { int k = 0; for (int i = 0; i < n_1; i++) { p_result[k] = plural1[i]; k++; } for (int i = 0; i < n_2; i++) { p_result[k] = plural2[i]; k++; } } void substraction_plural(int* plural1, int& n_1, int* plural2, int n_2) { int k = 0; int p = n_1 - 1; for (int i = 0; i < n_1; i++) { for (int j = 0; j < n_2; j++) { if (plural1[i] == plural2[j]) { swap(plural1[i], plural1[p]); p--; n_1--; } } } }
0
|
|
| 22.12.2021, 18:11 | |
|
Ответы с готовыми решениями:
0
Перевод кода с С++ на Python
|
| 22.12.2021, 18:11 | |
|
Помогаю со студенческими работами здесь
1
Перевод кода из Pascal в Python Перевод кода из С++ в Python
Перевод кода с Js на Python Перевод кода из С++ в Python Искать еще темы с ответами Или воспользуйтесь поиском по форуму: |
|
Новые блоги и статьи
|
|||
|
Восстановить юзерскрипты Greasemonkey из бэкапа браузера
damix 15.01.2026
Если восстановить из бэкапа профиль Firefox после переустановки винды, то список юзерскриптов в Greasemonkey будет пустым.
Но восстановить их можно так.
Для этого понадобится консольная утилита. . .
|
Изучаю kubernetes
lagorue 13.01.2026
А пригодятся-ли мне знания kubernetes в России?
|
Сукцессия микоризы: основная теория в виде двух уравнений.
anaschu 11.01.2026
https:/ / rutube. ru/ video/ 7a537f578d808e67a3c6fd818a44a5c4/
|
WordPad для Windows 11
Jel 10.01.2026
WordPad для Windows 11
— это приложение, которое восстанавливает классический текстовый редактор WordPad в операционной системе Windows 11. После того как Microsoft исключила WordPad из. . .
|
|
Classic Notepad for Windows 11
Jel 10.01.2026
Old Classic Notepad for Windows 11
Приложение для Windows 11, позволяющее пользователям вернуть классическую версию текстового редактора «Блокнот» из Windows 10. Программа предоставляет более. . .
|
Почему дизайн решает?
Neotwalker 09.01.2026
В современном мире, где конкуренция за внимание потребителя достигла пика, дизайн становится мощным инструментом для успеха бренда. Это не просто красивый внешний вид продукта или сайта — это. . .
|
Модель микоризы: классовый агентный подход 3
anaschu 06.01.2026
aa0a7f55b50dd51c5ec569d2d10c54f6/
O1rJuneU_ls
https:/ / vkvideo. ru/ video-115721503_456239114
|
Owen Logic: О недопустимости использования связки «аналоговый ПИД» + RegKZR
ФедосеевПавел 06.01.2026
Owen Logic: О недопустимости использования связки «аналоговый ПИД» + RegKZR
ВВЕДЕНИЕ
Введу сокращения:
аналоговый ПИД — ПИД регулятор с управляющим выходом в виде числа в диапазоне от 0% до. . .
|