题目:
代码:
#include "pch.h"
#include <iostream>
using namespace std;
class ARRAY {
private:
float a[10];
float b[10];
public:
ARRAY(float t[10])
{
for (int i = 0; i < 10; i++)
{
a[i] = t[i];
}
}
void process()
{
b[0] = (a[0] + a[1] + a[9]) / 3;
b[9] = (a[0] + a[9] + a[8]) / 3;
for (int i = 1; i < 9; i++)
{
b[i] = (a[i - 1] + a[i] + a[i + 1]) / 3;
}
}
void print()
{
for (int i = 0; i < 10; i++)
{
cout << a[i] << " " << endl;
}
for (int i = 0; i < 10; i++)
{
cout << b[i] << " " << endl;
}
}
};
int main()
{
float t[10];
for (int i = 0; i < 10; i++)
{
t[i] = (float)i;
}
ARRAY buf(t);
buf.process();
buf.print();
}