程序执行到fun()函数后就执行不下去了。应该是执行了一次循环后就不行了。
试试这样(未测试)
int main()
{
Node *arr1, *arr2;
arr1 = arr2 = NULL;
while (true) {
int temp;
cin >> temp;
if (temp == 0) {
break;
}
arr1 = new Node;
arr1->data = temp;
arr1->next = NULL;
}
cout << func(arr2) << endl;
return 0;
}