Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <graphics.h>
- const int N = 3;
- int main() {
- initwindow(800,600);
- int px = 450, py = 400;
- int x0 = 200, y0 = 500;
- int d = 50, ds = 50, dc = 80;
- double first[N] = {100, 240, 360};
- double second[N] = {90, 100, 340};
- double third[N] = {34, 20, 40};
- double max = first[0];
- for(int i = 0; i < N; i++) {
- if (first[i] > max)
- max = first[i];
- if (second[i] > max)
- max = second[i];
- if (third[i] > max)
- max = third[i];
- }
- double s = max / px;
- // Izchertavane na osite
- line(x0, y0, x0 + px, y0);
- line(x0, y0, x0, y0 - py);
- int j1 = px / d;
- char t[10];
- for(int i = 1; i <= j1; i++) {
- line(x0 + i * d, y0, x0 + i * d, y0 + 10);
- gcvt(i * d * s, 5.2, t);
- outtextxy(x0 + i * d - 10, y0 + 20, t);
- }
- // Izchertavane na nadpisite
- for(int i = 0; i < N; i++) {
- char year[5];
- switch(i) {
- case 0: strcpy(year, "2017"); break;
- case 1: strcpy(year, "2018"); break;
- case 2: strcpy(year, "2019"); break;
- }
- outtextxy(x0 - 50 , y0 - (i+1)*(ds + dc) + 15, year);
- }
- // Izchertavane na stulbovete
- for(int i = 0; i < N; i++) {
- setfillstyle(3, 2);
- bar(x0, y0 - (i+1)*(ds + dc), x0 + first[i] / s, y0 - (i+1)*(ds + dc) + ds);
- setfillstyle(3, 9);
- bar(x0, y0 - (i+1)*(ds + dc), x0 + second[i] / s, y0 - (i+1)*(ds + dc) + ds);
- setfillstyle(3, 12);
- bar(x0, y0 - (i+1)*(ds + dc), x0 + t[i] / s, y0 - (i+1)*(ds + dc) + ds);
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement