I am trying to figure out a general form of this hypothetical example using C++.

I have a vector with any three numbes. I want the first numbers and third numbers in the vectors to not be changed, however for the second number, I would like the number to be average with the first number, the second number, and the third number in the vector which will replace the second number in the final output.

I was wondering if iostream <vector> approach is necessary?

Code:
#include <iostream>
#include<vectors>?
using namespace std;

int main()

{

const int numberofterms=3
double Temperature[numberofterms]={22,24,16.2}
float average

If (first vector number and third vector number are chosen:) THEN

The first vector and the third vector are kept. 

Else The second vector will be replaced by the average.

average = (Temperature[0]+Temperature [1]+Temperature [2])/numberofterms;

}
The displaying part would not be a problem but just the way to write this in C++ I am having a really difficult time to find examples of what I am looking for. Thanks again.!