-
Notifications
You must be signed in to change notification settings - Fork 1
/
game.c
72 lines (59 loc) · 1.72 KB
/
game.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdio.h>
#include <string.h>
#define TEAMS 4 // Defining number of teams
#define HWIN 2 // Defining number of home wins
#define AWIN 3 // Defining number of away wins
#define DRAW 1 // Defining number of draws
#define LOSS -1 // Defining number of loses
#define NAMELEN 20 // Defining name length
struct team
{
char name[NAMELEN]; // Team name
int points; // Total Points
int played; // Number of games played
int scoreHome; // Gets score from each home win
int scoreAway; // Gets score from each away team
};
struct league
{
struct team table[TEAMS]; // Table for the whole league
};
// Prototype of function that i will create
int main(void)
{
int i;
struct league theLeague; // Below shows what will be input onto the screen
puts("Football League");
puts("=============== \n");
puts("Enter The Name Of Teams");
puts("=======================");
for (i=0; i<TEAMS; i++) // i = 0 next time through the loop adds 1 until i reaches 10
{
printf("\nTeam %d ", i+1); // Ask for each team
gets(theLeague.table[i].name); // Gets each team from the keyboard
fflush(stdin);
}
for (i=0; i<TEAMS; i++)
{
printf("\nTeam %s\n",theLeague.table[i].name); // This then shows the teams entered
}
for (i=0; i<TEAMS; i++)
{
int scoreHome;
{
printf("\nEnter Home Score for %s: ", theLeague.table[i].name); // Will enter home score of teams
scanf("\n&theLeague.table[i].scoreHome");
fflush(stdin);
}
}
for (i=0; i<TEAMS; i++)
{
int scoreAway;
{
printf("\nEnter Away Score for %s: ", theLeague.table[i].name); // Will enter away score of teams
scanf("\n&theLeague.table[i].scoreAway");
fflush(stdin);
}
}
return 0;
}