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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
void Base (int listB [], int numberOfRows, int startingPoint, int increment);
void PrintAll (int listB [], int listS[], int nRows);
void Square (int listB [], int listS[], int numberOfRows);
void SqRoot (int listB[], double ListSQR [], int numberOfRows);
int main() {
int arraySizeB [25];
int arraySizeS [25];
double arraySizeSQR [25];
int size;
cout << "Enter the number of rows in your table between 1 and 25: ";
cin >> size;
cout << endl;
while (size < 1 || size > 25)
{
cout << "Invalid input" << endl;
cout << "Please enter a valid Number of rows in your table between 1 and 25: ";
cin >> size;
}
int startPoint;
cout << "Enter a number to start the table with between - 1000 and 1000: ";
cin >> startPoint;
cout << endl;
while (startPoint < -1000 || startPoint > 1000)
{
cout << "Invalid input" << endl;
cout << "Please enter a valid Number to start the table with between -1000 and 1000: ";
cin >> startPoint;
}
int increment;
cout << "Enter a number to increment table between 1 and 20: ";
cin >> increment;
cout << endl;
while (increment < 1 || increment > 20)
{
cout << "Invalid input" << endl;
cout << "Please enter a valid Number to increment table between 1 and 20: ";
cin >> increment;
}
Base(arraySizeB, size, startPoint,increment);
//Square(arraySizeB,arraySizeS,size);
//PrintAll(arraySizeB, arraySizeS,size);
for (int index = 0; index < size ; index++)
{
double newValue = sqrt(arraySizeB[index]);
arraySizeSQR[index] = newValue;
if (newValue != '0')
{
arraySizeSQR[index] = "N/A"
}
}
return 0;
}
void Base (int list[], int numberOfRows, int startingPoint, int increment)
{
list [0] = startingPoint;
for (int index = 1; index < numberOfRows; index++)
{
int newValue = startingPoint += increment;
list[index] = newValue;
}
}
void Square (int listB [], int listS[], int numberOfRows)
{
for (int index = 0; index < numberOfRows ; index++)
{
int newValue = listB[index] * listB[index];
listS[index] = newValue;
}
}
void SqRoot (int listB[], double listSQR [], int numberOfRows)
{
for (int index = 0; index < numberOfRows ; index++)
{
double newValue = sqrt(listB[index]);
listSQR[index] = newValue;
}
}
void PrintAll (int listB [], int listS[], int nRows)
{
for (int j = 0; j < nRows; j ++)
{
cout << listB [j] << " " << listS[j] << endl;
}
}
|