<code>#include<iostream>
using namespace std;
void FindCommonChar(char a[], int lena, char b[], int lenb)
{
int hasha[256] = {0};
int hashb[256] = {0};
for (int i = 0; i < lena; i++)
{
hasha[(int)a[i]] = 1;
}
for (int j = 0; j < lenb; j++)
{
hashb[(int)b[j]] = 1;
}
for (int i = 0; i < 256; i++)
{
if (hasha[i] == 1 && hashb[i] == 1)
{
std::cout << (char)i << std::endl;;
}
}
}
int main()
{
char a[5] = {'1', 'b', 'C', 'f', 'f'};
char b[6] = {'1', 'b', 'd', 'e', 'C','d'};
FindCommonChar(a, 5, b, 6);
return 0;
}
/<iostream>/<code>
閱讀更多 程序員的酒和故事 的文章