mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-05-11 11:07:27 +08:00
style: format code
This commit is contained in:
@@ -1,33 +1,34 @@
|
||||
#include <iostream>
|
||||
int main()
|
||||
{
|
||||
int m,n,i=0,j=0;
|
||||
cout << "Enter size of both arrays:";
|
||||
cin >> m >> n;
|
||||
int a[m];
|
||||
int b[n];
|
||||
cout << "Enter elements of array 1:";
|
||||
for(i=0;i<m;i++)
|
||||
cin >>a[i];
|
||||
cout << "Enter elements of array 2:";
|
||||
for(i=0;i<n;i++)
|
||||
int m, n, i = 0, j = 0;
|
||||
cout << "Enter size of both arrays:";
|
||||
cin >> m >> n;
|
||||
int a[m];
|
||||
int b[n];
|
||||
cout << "Enter elements of array 1:";
|
||||
for (i = 0; i < m; i++)
|
||||
cin >> a[i];
|
||||
cout << "Enter elements of array 2:";
|
||||
for (i = 0; i < n; i++)
|
||||
cin >> b[i];
|
||||
i=0;j=0;
|
||||
while((i<m)&&(j<n))
|
||||
{
|
||||
if(a[i]<b[j])
|
||||
cout << a[i++] <<" ";
|
||||
else if(a[i]>b[j])
|
||||
cout << b[j++] <<" ";
|
||||
i = 0;
|
||||
j = 0;
|
||||
while ((i < m) && (j < n))
|
||||
{
|
||||
if (a[i] < b[j])
|
||||
cout << a[i++] << " ";
|
||||
else if (a[i] > b[j])
|
||||
cout << b[j++] << " ";
|
||||
else
|
||||
{
|
||||
cout << a[i++];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
while(i<m)
|
||||
cout<< a[i++] <<" ";
|
||||
while(j<n)
|
||||
cout<< b[j++]<<" ";
|
||||
return 0;
|
||||
}
|
||||
while (i < m)
|
||||
cout << a[i++] << " ";
|
||||
while (j < n)
|
||||
cout << b[j++] << " ";
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user