我正在编写一个函数定义,让用户输入数组的元素但是得到错误 cin >> a[index];
void show(const double a[], unsigned els) {
size_t index = 0;
for (index = 0; index < els; index++) {
cin >> a[index];
}
for (index = 0; index < els; index++) {
if (a[index] == a[0]) {
cout << "{" << a[index] << ",";
}
else if (a[index] == a[els - 1]) {
cout << a[index] << "}";
}
else { cout << a[index] << ","; }
}
cout << endl;
}
Run Code Online (Sandbox Code Playgroud)