1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <iostream>
#include <cmath>
using namespace std;
double calculations(double [], const int);
void output(double[], const int);
int main()
{
const int arraySize = 50;
double numbers[arraySize];
calculations(numbers, arraySize);
output(numbers, arraySize);
return 0;
}
double calculations(double nums[], const int size)
{
int index;
int index2;
int num[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50};
for (index = 0; index < size/2; index++)
nums[index] = pow(num[index], 2);
for (index2 = index; index2 < size; index2++)
nums[index2] = pow(num[index2], 3);
return *nums;
}
void output(double nums[], const int size)
{
for(int i=0; i<size; i++)
{
cout << i+1 << ":" << nums[i] << endl;
}
}
|