Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by NguyenVietNamSon ( 6 years ago )
#include <iostream>
using namespace std;
void tachMangPhanBiet(int a[], int lengthA, int b[], int &lengthB)
{
lengthB = 0;
b[lengthB++] = a[0];
for (int i = 1; i < lengthA; i++)
{
bool flag = true;
for (int j = 0; j < lengthB; j++)
{
if (a[i] == b[j])
{
flag = false;
break;
}
}
if (flag)
{
b[lengthB++] = a[i];
}
}
}
void xuatMang(int a[], int length)
{
for (int i = 0; i < length; i++)
{
cout << a[i] << " ";
}
}
int main()
{
int a[] = {1, 2, 2, 3, 3, 0, 0, 0, 0, 4, 5, 6, 4, 7, 5, 0, 8};
const int lengthA = sizeof(a) / sizeof(a[0]);
int b[lengthA];
int lengthB;
cout << "M?ng A là: ";
xuatMang(a, lengthA);
tachMangPhanBiet(a, lengthA, b, lengthB);
cout << "\nM?ng B là: ";
xuatMang(b, lengthB);
system("pause");
return 0;
}
Revise this Paste