#include<stdio.h>
#include<conio.h>
#define m 5
void main()
{
	int sal[m],cl[m],i=0,j;
	int a1=0,a2=0,b1=0,b2=0,split;
	float gi[m];
	clrscr();
	printf("\nEnter salary and class for 5 people,Class '1'for risk,'0'for no risk:");
	for(;i<m;i++)
	{
		printf("\nEnter Salary:");
		scanf("%d",&sal[i]);
		printf("\nEnter Class:");
		scanf("%d",&cl[i]);
	}
	for(;i<m;i++)
	{
		split=sal[i];
		for(j=0;j<m;j++)
		{
			if(sal[j]<=split && cl[j]==1)
				a1++;
			else if(sal[j]<=split && cl[j]==0)
				b1++;
			else if(sal[j]>split && cl[j]==1)
				a2++;
			else
				b2++;
		}
		gi[i]=2/m*(a1*a2/(a1+a2)+b1*b2/(b1+b2));
	}
	for(;i<m;i++)
	 printf("\nGini Index for split %d is:%f",i+1,gi[i]);
	getch();
}