/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>

#define MAXX 80
#define MAXY 25

void tegn(int tal[3])
{
    int i,sum;
    int x,y;
    float frac[3];
    sum=0;
    for(i=0;i<3;i++) sum+=tal[i];
    for(i=0;i<3;i++) frac[i]=((double)tal[i])/sum+((i>0)?frac[i-1]:0.0);
    for(x=MAXX-4;x<=MAXX;x++)
    {
        for(y=1;y<=MAXY;y++)
        {
            gotoxy(x,y);
            if(y<frac[0]*MAXY)
               textbackground(GREEN);
            else if(y<frac[1]*MAXY)
               textbackground(YELLOW);
            else if(y<frac[2]*MAXY)
               textbackground(RED);
            cprintf(" ");
        }
    }
}

int main()
{
    int tal[3] = { 5, 10, 15 }; 
    clrscr();
    tegn(tal);
    getch();
}
