Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Заданы два массива – А(5) и В(4). Первым на печать вывести массив, сумма значений которого окажется наименьшей.
- */
- #include "pch.h"
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- int sum1, sum2;
- int *A = new int[5];
- int *B = new int[4];
- cout << "vvedite A" << endl;
- for (int i=0; i < 5; i++)
- {
- cin >> A[i];
- }
- cout << "vvedite B" << endl;
- for (int i = 0; i < 4; i++)
- {
- cin >> B[i];
- }
- sum1 = A[0];
- sum2 = B[0];
- for (int i = 1; i < 5; i++)
- {
- sum1 += A[i];
- }
- for (int i = 1; i < 4; i++)
- {
- sum2 += B[i];
- }
- cout<<endl << endl;
- if (sum1<sum2)
- {
- for (int i = 0; i < 5; i++)
- {
- cout << A[i] << " ";
- }
- cout << endl;
- for (int i = 0; i < 4; i++)
- {
- cout << B[i] << " ";
- }
- cout << endl;
- }
- else {
- for (int i = 0; i < 4; i++)
- {
- cout << B[i] << " ";
- }
- cout << endl;
- for (int i = 0; i < 5; i++)
- {
- cout << A[i] << " ";
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement