Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <graphics.h>
- #include <limits.h>
- using namespace std;
- void MinMax(int n, double arr[], double &min, double &max){
- for(int i= 0; i<n; i++){
- if(arr[i] > max) max = arr[i];
- if(arr[i] < min) min = arr[i];
- }
- }
- void Points(int n, double vhx[], double vhy[], double x0, double y0, double xmin, double ymin, double Sx, double Sy, double Sp, double Sl){
- for(int i = 0; i < n; i++){
- int xp = x0+(vhx[i] - xmin);
- int yp = y0-(vhy[i] - ymin);
- putpixel(xp,yp,7);
- }
- for(int i = 1; i < n; i++){
- line(x0+vhx[i-1], y0-vhy[i-1], x0+vhx[i], y0-vhy[i]);
- }
- }
- void Axis(int dir, double x0, double y0, double P, double D, double Min, double S){
- if(dir == 1){
- line(x0, y0, x0+P, y0);
- int Ip = P/D;
- for(int i = 0; i<Ip; i++){
- line(x0+i*D,y0,x0+i*D,y0+5);
- char k[100];
- gcvt(Min+i*D*S,3,k);
- outtextxy(x0+i*D,y0+15,k);
- }
- }
- else {
- line(x0, y0, x0, y0-P);
- int Jp = P/D;
- for(int j = 0; j < Jp; j++){
- line(x0,y0-j*D,x0-5,y0-j*D);
- char k[100];
- gcvt(Min+j*D*S,3,k);
- outtextxy(x0-35,y0-j*D-5,k);
- }
- }
- }
- int main() {
- int n = 8;
- double x0 = 50;
- double y0 = 600;
- double Px = 600;
- double Py = 550;
- double Dx = 40;
- double Dy = 40;
- double vhx[8] = {17.8, 1.3, 391.4, 61.4, 0.15, 581.52, 195.1, 124.73};
- double vhy[8] = {93.4, 0.2, 13.4, 64.4, 150.2, 518.52, 135.1, 74.73};
- double minX = INT_MAX;
- double minY = INT_MAX;
- double maxX = INT_MIN;
- double maxY = INT_MIN;
- initwindow(800,800, "p1");
- MinMax(n, vhx, minX, maxX);
- MinMax(n, vhy, minY, maxY);
- double Sx = (maxX - minX)/Px;
- double Sy = (maxY - minY)/Py;
- //Points(n, vhx, vhy, x0, y0, minX, minY, Sx, Sy, 0, 0);
- Axis(1,x0,y0,Px,Dx,minX,Sx);
- Axis(0,x0,y0,Py,Dy,minY,Sy);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement