/*************************************************************************/
#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<graphics.h>
int returnsingledigit(int);
void drawContainer(int,int,int);
int main()
{
int
gmode,gdriver=DETECT;
int
w1,w2;
initgraph(&gdriver,&gmode,"");
printf("enter
weight 1 : ");
scanf("%d",&w1);
printf("enter
weight 2 : ");
scanf("%d",&w2);
line(320,50,320,100);
//printf("%d%d",w1,w2);
if(w1>w2)
{
line(210,100+returnsingledigit(w1-w2)*10,430,100-returnsingledigit(w1-w2)*10);
drawContainer(210,100+returnsingledigit(w1-w2)*10,w1);
drawContainer(430,100-returnsingledigit(w1-w2)*10,w2);
}
else
if(w2>w1)
{
line(210,100-returnsingledigit(w2-w1)*10,430,100+returnsingledigit(w2-w1)*10);
drawContainer(210,100-returnsingledigit(w2-w1)*10,w1);
drawContainer(430,100+returnsingledigit(w2-w1)*10,w2);
}
else
{
line(210,100,430,100);
drawContainer(210,100,w1);
drawContainer(430,100,w2);
}
getch();
return
0;
}
void drawContainer(int x,int y,int data)
{
line(x,y,x,y+50);
rectangle(x-25,y+50,x+25,y+100);
}
int returnsingledigit(int n)
{
int
count=0,i,cn,result;
cn=n;
while(cn)
{
count++;
cn/=10;
}
//printf("%d",count);
for(i=0;i<count-1;i++)
n/=10;
return
n;
}
/*************************************************************************/
No comments:
Post a Comment