Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #include <graphics.h>
  2.  
  3. const int N = 3;
  4. int main() {
  5. initwindow(800,600);
  6. int px = 450, py = 400;
  7. int x0 = 200, y0 = 500;
  8. int d = 50, ds = 50, dc = 80;
  9.  
  10. double first[N] = {100, 240, 360};
  11. double second[N] = {90, 100, 340};
  12. double third[N] = {34, 20, 40};
  13.  
  14. double max = first[0];
  15. for(int i = 0; i < N; i++) {
  16. if (first[i] > max)
  17. max = first[i];
  18. if (second[i] > max)
  19. max = second[i];
  20. if (third[i] > max)
  21. max = third[i];
  22. }
  23.  
  24. double s = max / px;
  25.  
  26. // Izchertavane na osite
  27. line(x0, y0, x0 + px, y0);
  28. line(x0, y0, x0, y0 - py);
  29.  
  30. int j1 = px / d;
  31. char t[10];
  32. for(int i = 1; i <= j1; i++) {
  33. line(x0 + i * d, y0, x0 + i * d, y0 + 10);
  34. gcvt(i * d * s, 5.2, t);
  35. outtextxy(x0 + i * d - 10, y0 + 20, t);
  36. }
  37.  
  38. // Izchertavane na nadpisite
  39. for(int i = 0; i < N; i++) {
  40. char year[5];
  41. switch(i) {
  42. case 0: strcpy(year, "2017"); break;
  43. case 1: strcpy(year, "2018"); break;
  44. case 2: strcpy(year, "2019"); break;
  45. }
  46.  
  47. outtextxy(x0 - 50 , y0 - (i+1)*(ds + dc) + 15, year);
  48. }
  49.  
  50.  
  51. // Izchertavane na stulbovete
  52. for(int i = 0; i < N; i++) {
  53. setfillstyle(3, 2);
  54. bar(x0, y0 - (i+1)*(ds + dc), x0 + first[i] / s, y0 - (i+1)*(ds + dc) + ds);
  55. setfillstyle(3, 9);
  56. bar(x0, y0 - (i+1)*(ds + dc), x0 + second[i] / s, y0 - (i+1)*(ds + dc) + ds);
  57. setfillstyle(3, 12);
  58. bar(x0, y0 - (i+1)*(ds + dc), x0 + t[i] / s, y0 - (i+1)*(ds + dc) + ds);
  59. }
  60.  
  61. getch();
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement