Your last addition to the post makes it a bit more clear.
You wait for 3 child processes like this:
wait(&team1);
wait(&team2);
wait(&team3);
So team1..team3 will have the exit code of those processes. But the function wait
does not wait for any specific process, the first wait will return the exit code of the first child process exiting. So you will never know whether team1 will be the score of team1 or team2 or team3!
Because the child processes sleep depending on the score, the first process which stops will have the lowest score, because processes with a higher score sleep longer. So in your case team1 will always be the team with the lowest score.
5
solved Compare number dont work properly in C