fursty

histograma2

Mar 6th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <graphics.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9. int x0(200),y0(450),Px(500),Py(400);
  10. int a[] ={1,2,3,4,5,6,7,8,9,10,11,12};
  11. double Ds(20),Dc(40);
  12. int amin = a[0], amax = a[0];
  13. double s = (amax - amin) / (Py/Px);
  14.  
  15. for (int i=1;i<12;i++)
  16. {
  17. if (amin > a[i]) amin = a[i];
  18. if (amax < a[i]) amax = a[i];
  19. }
  20.  
  21. initwindow(800,600);
  22. line (200, 450, 200+Px, 450);
  23. line (200, 450, 200, 450-Py);
  24.  
  25.  
  26. for(int i=1; i<=12; i++)
  27. {
  28. bar(x0 + i*(Dc+Ds) - Ds, y0 - (a[i]/s), x0 + i*(Dc+Ds), y0);
  29. }
  30.  
  31.  
  32. getch();
  33. return 0;
  34. }
Add Comment
Please, Sign In to add comment