Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include "windows.h"
- using namespace std;
- void SetColor(int text, int background)
- {
- HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hStdOut, (WORD)((background << 4) | text));
- }
- int main() {
- setlocale(0,"");
- int n;
- double a[100], x, p = 0;
- cout << "Поліном Р(х)=an*x^n+a(n-1)*x^(n-1)+...a1*x+a0";
- do {
- cout << "\nКількість елементів масиву = ";
- cin >> n;
- } while (n <= 0 || n > 99);
- for (int i = 0; i < n; i++) {
- cout << 'a' << i+1 << "= ";
- cin >> a[i];
- }
- for (int i = 0; i < n; i++) {
- SetColor(4,0);cout << a[i] << '\t';SetColor(7,0);
- }
- cout << "\nВведіть дійсне число х = ";SetColor(5,0);
- cin >> x;SetColor(4,0);
- for (int i = 0; i < n; i++) {
- p += a[i] * pow(x, i);
- if (p >= 2000000000) { cout << "Переповнення!";
- break;}
- }
- cout << "P(" << x << ')' << '=' << p;SetColor(7,0);
- return 0;
- }
Add Comment
Please, Sign In to add comment