S, i was creating some game based on random value. This game should predict how the soccer game will turn out by inserting the stat of the player for one team combined and the other combined and so on. The team that put on game stat will add by the rival stat. The original stat of the player would be divided by two and put in the edge of the probability bar if the value touch the stat of the team it will consider score but if it's in the middle it would become draw.
Here's the code
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <time.h>
int score_prob(int x,int hh, int aw);
int main()
{
int i,j,k,a,b,c,n,sc,shome=0,saway=0;
int p[64][64],x,y,z,ho,aw;
int t[64],h,w,sem,tand;
printf("Number Of Team : ");scanf("%d",&x);
printf("Number Of Player: ");scanf("%d",&y);
for(i=0;i<x;i++)
{
z = 0;
printf("\n\n");
printf("Teamm %d \n",i+1);
for(j=0;j<y;j++)
{
printf(". PLayer %d : " ,(j+1));scanf("%d",&p[i][j]);
z += p[i][j];
}
printf("Stat of team %d = %d",i+1,z);
t[i] = z;
}
srand(time(NULL));
do
{
k = 0;
printf("\n\n");
printf("Home Team Number: ");scanf("%d",&a);a = a - 1;
printf("Away Team Number: ");scanf("%d",&b);b = b - 1;
for(i=0;i<90;i++)
{
i += 4;
printf("\nMinute %d: ",i+1);
{
sem = t[a] + t[b];
ho=t[a];aw=t[b];
sc = score_prob(sem,ho,aw);
printf("\n %d\n",score_prob(sem,t[a],t[b]));
if(sc == 0)
{
shome += 1;
printf("Home Score\n");printf(" %d VS %d ",shome,saway);
}else if(sc == 2)
{
printf(" %d VS %d ",shome,saway);
}
else{
saway += 1;
printf("Away Score\n");printf(" %d VS %d ",shome,saway);
}
}
}
}while(k == 0);
return 0;
}
int score_prob(int x,int hh, int aw)
{
int st,aa,nn,sr=0,sh=0,sa=0,home,away;
time_t t;
sh=0;sa=0;
aw = aw / 2; hh = hh / 2;
srand((unsigned) time(&t));
for(nn=0;nn<x;nn++)
{
aa = rand() % x;
if(aa<hh)
{
sh += 1;
}
if(aa>(aa - aw))
{
sa += 1;
}
if(aa!=(aa<hh) && aa != (aa<(aa-aw)))
{
sr +=1;
}
}
if(sr != 0)
{
if(sh<sa)
{
st = 1;
}
else
{
st = 0;
}
}
else
{
st = 2;
}
return st;
}