Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <winbgim.h>
- using namespace std;
- const int WID = 800, HIGH = 600, scale = 50;
- const double step = 0.01;
- void drawLine(int moveToX, int moveToY, int drawX, int drawY, int color, int textX, int textY, char *name) {
- moveto(moveToX, moveToY);
- setcolor(color);
- lineto(drawX, drawY);
- outtextxy(textX, textY, name);
- }
- int main() {
- double y1, y2;
- initwindow(WID, HIGH);
- moveto(WID / 2, HIGH / 2);
- vector<double> ab;
- bool xo;
- moveto(WID / 2 + (WID*WID * scale), HIGH / 2 - (WID*WID * scale));
- for (double x1 = -WID; x1 < WID; x1 += step) {
- y1 = 2;
- setcolor(15); // Oaao ooieoee
- lineto((WID / 2) + (x1 * scale), (HIGH / 2) - (y1 * scale));
- }
- moveto(WID / 2, HIGH / 2);
- moveto(WID / 2 + (-WID * scale), HIGH / 2 - (25-(-WID*-WID)) * scale);
- for (double x2 = -WID; x2 < WID; x2 += step) {
- y1 = 2;
- y2 = sqrt(25-x2*x2);
- setcolor(15); // Oaao ooieoee
- lineto(WID / 2 + (x2 * scale), HIGH / 2 - (y2 * scale));
- if(y1-step<y2&&y2<y1+step) ab.push_back(x2);
- }
- moveto(WID / 2, HIGH / 2);
- setcolor(15);
- outtextxy(460,30,"y=sqrt(25-x*x)");
- outtextxy(680,150,"y=2");
- cout << "a = " << ab[0] << endl;
- cout << "b = " << ab[1] << endl;
- outtextxy(WID/2 + (ab[0]*scale), HIGH/2,"a");
- outtextxy(WID/2 + (ab[1]*scale), HIGH/2,"b");
- drawLine(0, HIGH / 2 - 2, WID, HIGH / 2 - 2, 15, WID - 20, HIGH / 2 + 10, "X");
- drawLine(WID / 2, 0, WID / 2, HIGH, 15, WID / 2 + 10, 0, "Y");
- setfillstyle(1,COLOR(60, 179, 113));
- floodfill(WID / 2 + (-1 * scale), HIGH / 2 - (1 * scale), 15);
- floodfill(WID / 2 + (1 * scale), HIGH / 2 - (1 * scale), 15);
- getch();
- closegraph();
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement