分析程序,写出运行结果。 #include
using namespace std; int f(int *a, int *b, int *c, int *d) { int n = 0; while (a != b) { if (*a == *c) { *d = *a; ++n, ++d; } ++a, ++c; } return n; } int main() { int a[] = {1, 2, 4, 5, 6, 7}; int n = sizeof(a) / sizeof(*a); int b[] = {0, 2, 3, 4, 6, 7, 8}; int c[10]; int m = f(a, a + n, b, c); for (int i = 0; i < m; ++i) cout << c[i] << "\t"; }