Archived
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
#include <iostream>
|
|
#include <graphics.h>
|
|
|
|
using namespace std;
|
|
|
|
|
|
void drawGrid() {
|
|
for (int i = 0; i <= 600; i += 20) {
|
|
line(i, 0, i, 600);
|
|
line(0, i, 600, i);
|
|
}
|
|
}
|
|
int main() {
|
|
// Óñòàíîâêà ãðàôè÷åñêîãî ðåæèìà
|
|
int gd = DETECT, gm;
|
|
initgraph(&gd, &gm, "");
|
|
|
|
drawGrid();
|
|
setcolor(12);
|
|
// Îñè êîîðäèíàò
|
|
line(200, 260, 400, 260); // îñü X
|
|
line(300, 360, 300, 160); // îñü Y
|
|
// line(320, 340, 400, 220);
|
|
|
|
// Ðèñîâàíèå ãðàôèêà
|
|
for (int x = 0; x <= 600; x++) {
|
|
float y = 1.25*x - 4.25; // Âû÷èñëåíèå y ïî ãðàôèêó
|
|
putpixel(580-x, (int)y, 2);
|
|
}
|
|
bar(0,0,500,100);
|
|
// Òåêñò óñëîâèÿ
|
|
setcolor(14);
|
|
outtextxy(10, 10, "a = y2 - y1 / x2 - x1 = 2 - (-3) / 5 - 1 = 2 + 3 / 5 - 1 = 5 / 4");
|
|
outtextxy(10,30, "-3 = 5 / 4 * 1 + b ---> -3 = 5 / 4 + b");
|
|
outtextxy(10,50, "b = -3 - 5 / 4 = -12 / 4 - 5 / 4 = -17 / 4");
|
|
// Òåêñò îòâåòà
|
|
outtextxy(10, 70, "Answer: f(11) = 1.25 * 11 - 4.25 = 9.5");
|
|
printf("a = y2 - y1 / x2 - x1 = 2 - (-3) / 5 - 1 = 2 + 3 / 5 - 1 = 5 / 4");
|
|
printf("-3 = 5 / 4 * 1 + b ---> -3 = 5 / 4 + b");
|
|
printf("b = -3 - 5 / 4 = -12 / 4 - 5 / 4 = -17 / 4");
|
|
printf("Answer: f(11) = 1.25 * 11 - 4.25 = 9.5");
|
|
|
|
getch();
|
|
closegraph();
|
|
return 0;
|
|
}
|
|
|