#include #include #include #include using namespace std; char cornerLeftTop = 201; char cornerRightTop = 187; char cornerLeftBottom = 200; char cornerRightBottom = 188; char verticalLine = 186; char horizontalLine = 205; string titleOne = " Function #1 "; string titleTwo = " Function #2 "; string titleThree = " Function #3 "; void printTitle(string titleName) { char title = 177; for (int i = 0; i < 30; i++) { cout << title; } cout << titleName; for (int i = 0; i < 30; i++) { cout << title; } cout << endl; } void topTable() { cout << cornerLeftTop; for (int i = 0; i < 71; i++) { cout << horizontalLine; } cout << cornerRightTop << endl; } void bottomTable() { cout << cornerLeftBottom; for (int i = 0; i < 71; i++) { cout << horizontalLine; } cout << cornerRightBottom << "\n\n"; } void FuncHorizontalLine() { cout << verticalLine; for (int i = 0; i < 71; i++) { cout << horizontalLine; } cout << verticalLine << endl; } void funcOne(vector vec) { printTitle(titleOne); topTable(); cout << verticalLine << setw(18) << "X" << setw(18) << verticalLine << setw(18) << "SIN(X)" << setw(18) << verticalLine << endl; FuncHorizontalLine(); for (float i = 0; i < 21; i++) { cout << verticalLine << setw(18) << vec[i] << setw(18) << verticalLine << setw(18) << sin(vec[i]) << setw(18) << verticalLine << endl; } bottomTable(); } void funcTwo(vector vec) { printTitle(titleTwo); topTable(); cout << verticalLine << setw(18) << "X" << setw(18) << verticalLine << setw(18) << "2X - 4X + 9" << setw(18) << verticalLine << endl; FuncHorizontalLine(); for (float i = 0; i < 21; i++) { cout << verticalLine << setw(18) << vec[i] << setw(18) << verticalLine << setw(18) << (2 * vec[i]) - (4 * vec[i]) + 9 << setw(18) << verticalLine << endl; } bottomTable(); } void funcThree(vector vec) { printTitle(titleThree); topTable(); cout << verticalLine << setw(18) << "X" << setw(18) << verticalLine << setw(18) << "X^2 - 16X + 4" << setw(18) << verticalLine << endl; FuncHorizontalLine(); for (float i = 0; i < 21; i++) { cout << verticalLine << setw(18) << vec[i] << setw(18) << verticalLine << setw(18) << pow(vec[i], 2) - (16 * vec[i]) + 4 << setw(18) << verticalLine << endl; } bottomTable(); } int main() { /* float *arrayX = new float [n]; for (float i = 0; i < n; i += 0.5){ elX = i + 0.5; arrayX[i] = elX; }*/ /* for (int i = 0; i < n; i++){ cout << arrayX[i]; }*/ vector myVector(21); float elemK = 0; for (float k = 0; k < 21; k++) { k != 0 ? elemK += 0.5 : elemK == 0; myVector[k] = elemK; } funcOne(myVector); funcTwo(myVector); funcThree(myVector); return 0; }