Reuniunea a 2 vectori C++ #include
using namespace std;
int main() {
int a[100], n = 5, b[100], m, c[200];
cout << "nr elem a: ";
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
cout << "nr elem b: "; cin >> m;
for (int j = 0; j < m; j++)
cin >> b[j];
int i = 0, j = 0, k = 0;
while ((i < n) && (j < m)) {
if (a[i] < b[j])
c[k + 1] = a[i + 1];
else
c[k + 1] = b[j + 1];
}
cout << c[k];
for (i = 0; i < n; i++)
c[k + 1] = a[i];
for (j = 0; j < m; j++)
c[k + 1] = b[j];
for (int j= 0; j< k; j++)
cout << c[K] << " ";
}
Aici e ce am incercat eu, daca se poate modifica acest cod ca sa mearga .
rezolvare de clasa a 10 a

Smile Life

Show life that you have a thousand reasons to smile

Get in touch

© Copyright 2024 DOKU.TIPS - All rights reserved.