Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. #include <iostream>
  2. #include"graphics.h"
  3. using namespace std;
  4.  
  5. void minmax(int n, double A[], double&Amin, double&Amax)
  6. {
  7. Amin=A[0];
  8. Amax=A[0];
  9.  
  10. for (int i=1; i<n; i++)
  11. {
  12. if(Amin>A[i])
  13. Amin=A[i];
  14. if(Amax<A[i])
  15. Amax=A[i];
  16. }
  17. }
  18.  
  19. void Histo(int Dir, int n,double VhodA[],int x0, int y0,double Amin, double s, int ds, int dc)
  20. {
  21. int x1;
  22. int x2;
  23. int y1;
  24. int y2;
  25.  
  26.  
  27. // int x0,y0;
  28.  
  29. for(int i=0; i<n; i++)
  30. {
  31. x1=x0+(i+1)*(ds+dc)-dc;
  32. y1=(y0-(VhodA[i]-Amin)/s);
  33. x2=x0+(i+1)*(ds+dc);
  34. y2=0;
  35. setfillstyle(1,i+3);
  36. bar(x1,y1,x2,y2);
  37. // xp=x0 + (Vhodx[i] - xmin)/sx;
  38. // yp=y0 - (VhodY[i] - ymin)/sy;
  39. // circle(xp,yp,5);
  40. //line (x0,y0,xp,yp);
  41. }
  42. }
  43.  
  44. void Axiis(int Dir, int x0,int y0, int D, double min, int P, double S)
  45. {
  46. double val;
  47. double I;
  48. char intStr[20];
  49. char* t;
  50. if(Dir!=0)
  51. {
  52. line (x0,y0,x0+P,y0);
  53. I=(P/D)-1;
  54. for (int i=0;i<I;i++)
  55. {
  56. line(x0+(i*D),y0,(x0+i*D),(y0+3));
  57. val=min+i*D;
  58. t=gcvt(val,10,intStr);
  59. settextjustify(1,2);
  60. outtextxy(x0+i*D,(y0+3),t);
  61. }
  62. }
  63. if (Dir==0)
  64. {
  65. line(x0,y0,x0,(y0-P));
  66. I=(P/D)-1;
  67. for(int i=0;i<I;i++)
  68. {
  69. line(x0,(y0-(i*D)),(x0-3),(y0-i*D));
  70. val=min+i*D;
  71. t=gcvt(val,10,intStr);
  72.  
  73. settextjustify(2,1);
  74. outtextxy(x0-3,(y0-i*D),t);
  75.  
  76. }
  77. }
  78. }
  79. int main()
  80. {
  81. initwindow(800,600,"");
  82.  
  83. double VhodA[6]={3.7, 4.5, 5.1, 6.9, 2.4, 3.1};
  84. // double VhodB[6,10]={5.7, 1.5, 2.1, 3.9, 4.4, 5.1, 8.2, 7.9};
  85.  
  86. int x0, y0, p, d, ds, dc ;
  87. x0=50;
  88. y0=500;
  89. p = 500;
  90. d=40;
  91. ds=40;
  92. dc=40;
  93.  
  94. double Amin, Amax, s;
  95. minmax(6,VhodA, Amin, Amax);
  96. if(Amin>0)
  97. Amin=0;
  98.  
  99. if(Amax<0)
  100. Amax=0;
  101. // minmax(8, VhodY, ymin, ymax);
  102. s=(Amax-Amin)/p;
  103.  
  104. Histo(0, 6,VhodA, x0, 500, Amin, s, ds, dc);
  105. // Axiis(1, x0, y0, s, Amin, p, d);
  106. // Axiis(0, x0,y0,50, px, sx);
  107.  
  108. getch();
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement