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 Histo(int Dir, int n,double VhodA[],int x0, int y0,double Amin, double s, int ds, int dc)
- {
- int x1;
- int x2;
- int y1;
- int y2;
- // int x0,y0;
- for(int i=0; i<n; i++)
- {
- x1=x0+(i+1)*(ds+dc)-dc;
- y1=(y0-(VhodA[i]-Amin)/s);
- x2=x0+(i+1)*(ds+dc);
- y2=0;
- setfillstyle(1,i+3);
- bar(x1,y1,x2,y2);
- // 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 VhodA[6]={3.7, 4.5, 5.1, 6.9, 2.4, 3.1};
- // double VhodB[6,10]={5.7, 1.5, 2.1, 3.9, 4.4, 5.1, 8.2, 7.9};
- int x0, y0, p, d, ds, dc ;
- x0=50;
- y0=500;
- p = 500;
- d=40;
- ds=40;
- dc=40;
- double Amin, Amax, s;
- minmax(6,VhodA, Amin, Amax);
- if(Amin>0)
- Amin=0;
- if(Amax<0)
- Amax=0;
- // minmax(8, VhodY, ymin, ymax);
- s=(Amax-Amin)/p;
- Histo(0, 6,VhodA, x0, 500, Amin, s, ds, dc);
- // Axiis(1, x0, y0, s, Amin, p, d);
- // Axiis(0, x0,y0,50, px, sx);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement