#includeusing 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;//记录a数组的所有字符 } for (int j = 0; j < lenb; j++) { hashb[(int)b[j]] = 1;//记录b数组的所有字符 } 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;}--------------------- 作者:一蓑烟雨1989 来源:CSDN 原文:https://blog.csdn.net/wangshubo1989/article/details/88618464 版权声明:本文为博主原创文章,转载请附上博文链接!