Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include"graphics.h"
- using namespace std;
- void minmax(int n, double A[], double&Amin, double&Amax)
- {
- Amin=A[0];
- Amax=A[0];
- for (int i=1; i<n; i++)
- {
- if(Amin<A[i])
- Amin=A[i];
- if(Amax>A[i])
- Amax=A[i];
- }
- }
- void points(int n,double Vhodx[], double VhodY[],double xmin,double ymin,int x0,int y0,double sx,double sy)
- {
- int xp,yp;
- // int x0,y0;
- for(int i=0; i<n; i++)
- {
- xp=x0 + (Vhodx[i] - xmin)/sx;
- yp=y0 - (VhodY[i] - ymin)/sy;
- circle(xp,yp,5);
- //line (x0,y0,xp,yp);
- }
- }
- void Axiis(int Dir, int x0,int y0, int D, double min, int P, double S)
- {
- double val;
- double I;
- char intStr[20];
- char* t;
- if(Dir!=0)
- {
- line (x0,y0,x0+P,y0);
- I=(P/D)-1;
- for (int i=0;i<I;i++)
- {
- line(x0+(i*D),y0,(x0+i*D),(y0+3));
- val=min+i*D;
- t=gcvt(val,10,intStr);
- settextjustify(1,2);
- outtextxy(x0+i*D,(y0+3),t);
- }
- }
- if (Dir==0)
- {
- line(x0,y0,x0,(y0-P));
- I=(P/D)-1;
- for(int i=0;i<I;i++)
- {
- line(x0,(y0-(i*D)),(x0-3),(y0-i*D));
- val=min+i*D;
- t=gcvt(val,10,intStr);
- settextjustify(2,1);
- outtextxy(x0-3,(y0-i*D),t);
- }
- }
- }
- int main()
- {
- initwindow(800,600,"");
- double VhodX[8]={3.7, 4.5, 5.1, 6.9, 2.4, 3.1, 9.2, 7.2};
- double VhodY[8]={5.7, 1.5, 2.1, 3.9, 4.4, 5.1, 8.2, 7.9};
- int px, py, y0, x0, dx, dy;
- x0=100;
- y0=500;
- px=500;
- py=300;
- dx=60;
- dy=60;
- double xmin, xmax, ymin, ymax, sx, sy;
- minmax(8,VhodX, xmin, xmax);
- minmax(8, VhodY, ymin, ymax);
- sx=(xmax-xmin)/px;
- sy=(ymax-ymin)/py;
- points(8,VhodX,VhodY,xmin,ymin,x0,y0,sx,sy);
- Axiis(1, x0,y0,50, xmin, px, sx);
- Axiis(0, x0,y0,50, ymin, px, sx);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement