Skip to content

Instantly share code, notes, and snippets.

@b-adams
Created December 12, 2012 03:17
Show Gist options
  • Save b-adams/4264593 to your computer and use it in GitHub Desktop.
Save b-adams/4264593 to your computer and use it in GitHub Desktop.
$ clang cs131_test_final_problem_1_lforce.c
$ ./a.out
Welcome to Nim
How many piles would you like to use? The number is usually 3, but this version allows up to ten.3
How many players will be in this game? No more than ten can play.Cannot be less than zero.
2
How many beans are in pile 1 to start with? (No more than 10)
Usually this pile has 3
Cannot be less than zero.
3
How many beans are in pile 2 to start with? (No more than 10)
Usually this pile has 4
Cannot be less than zero.
4
How many beans are in pile 3 to start with? (No more than 10)
Usually this pile has 5
Cannot be less than zero.
5
Player 1's turn
Pile 1: 3 beans
Pile 2: 4 beans
Pile 3: 5 beans
Which pile do you want to move from?1
How many beans do you want to take?2
DISPLAY PILE
0:3 1:4 2:5
Attempting to remove 2 from pile at index 48
DISPLAY PILE
0:3 1:4 2:5
Player 2's turn
Pile 1: 3 beans
Pile 2: 4 beans
Pile 3: 5 beans
Which pile do you want to move from?
if(true)
{
printf("DISPLAY PILE\n");
for(int i=0; i<piles; i++)
{
printf("%d:%d\t", i, Pile[i]);
}
printf("\n");
}
printf("Attempting to remove %d from pile at index %d\n", choiceOfNumber, choiceOfPile-1);
Pile[choiceOfPile-1] = (Pile[choiceOfPile-1] - choiceOfNumber) ;
if(true)
{
printf("DISPLAY PILE\n");
for(int i=0; i<piles; i++)
{
printf("%d:%d\t", i, Pile[i]);
}
printf("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment