问题:
解答:
#include <iostream>
using namespace std;
#define SIZE 10
double* fill_array(double* begin, double* end)
{
for (begin; begin < end; begin++)
{
cout << "请输入值:";
cin >> *begin;
if (cin.fail())
{
cout << "非法数字,结束输入!" << endl;
break;
}
}
return begin;
}
void show_array(double* arr, double* end)
{
double* n = arr;
cout << "数组信息为:";
for (n; n < end; n++)
{
cout << *n << " ";
}
cout << endl;
}
void revalue(double r, double* arr, double* end)
{
double* n = arr;
for (n; n < end; n++)
{
(*n) *= r;
}
}
int main()
{
double array[SIZE];
double* begin = &array[0];
double* end = &array[SIZE];
double *index=fill_array(begin, end);
show_array(array, index);
revalue(2, array, index);
show_array(array, index);
return 0;
}
运行结果:
考查点:
- 数组和指针
2024年8月30日21:16:55
标签:index,begin,end,cout,double,Plus,习题,Primer,array From: https://blog.csdn.net/qq_74047911/article/details/141727550