From e08e9f41b19762095dc726747f4e9f5d2ce8cf59 Mon Sep 17 00:00:00 2001 From: Rebecca Hale Date: Fri, 5 Aug 2016 11:18:54 -0400 Subject: [PATCH 1/2] Rebecca Hale Challenge1 --- hangman.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 hangman.c diff --git a/hangman.c b/hangman.c new file mode 100644 index 0000000..fcdd78b --- /dev/null +++ b/hangman.c @@ -0,0 +1,110 @@ +#include +#include +#include +#include +#include + +void choice1(char man[], int manSize, char blanks[], int answerSize, char answer[]){ + char guess[answerSize]; + printf("\n%s", man); + printf("\n%s", blanks); + printf("\nEnter your guess: "); + scanf("%s", &guess); + for(int i = 0; i4){ + printf("\n\n%s\n\n", man); + printf("\nSorry you lose!\n"); + printf("\nThe correct answer was %s\n", answer); + break; + } + printf("\n\nSorry, you guessed wrong!\n"); + man[manCharSpots[locationInMan]]=' ';/*deletes character in man*/ + locationInMan++; + printf("\n\n%s\n\n", man); + } + if(spot>=0){ + printf("\n\nYou guessed right!"); + blanks[spot]=answer[spot]; + printf("\n\n%s\n\n", blanks); + } + if(blanks[strlen(blanks)-1]!='_'){ + printf("\nCongratulations, you won!"); + printf("\nThe correct word was %s\n", answer); + break; + } + } + } + return 0; +} From 0d29f47ad0f398a085626178b08208576e5aae57 Mon Sep 17 00:00:00 2001 From: Rebecca Hale Date: Fri, 5 Aug 2016 11:21:24 -0400 Subject: [PATCH 2/2] Add files via upload --- minesweeper.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 minesweeper.c diff --git a/minesweeper.c b/minesweeper.c new file mode 100644 index 0000000..03bf6de --- /dev/null +++ b/minesweeper.c @@ -0,0 +1,110 @@ +#include +#include +#include + + +int main(){ + int dim1, dim2; + float prob; + + char line[100]; + while(1){ + printf("Enter first dimension: "); + fgets(line, sizeof(line), stdin); + if(sscanf(line, "%d", &dim1)) + break; + printf("\nYou did not enter a valid dimension.\n"); + }/*checks for invalid input*/ + while(1){ + printf("Enter second dimension: "); + fgets(line, sizeof(line), stdin); + if(sscanf(line, "%d", &dim2)) + break; + printf("\nYou did not enter a valid dimension.\n"); + }/*checks for invalid input*/ + + while(1){ + printf("Enter probability of mines: "); + fgets(line, sizeof(line), stdin); + if(sscanf(line, "%f", &prob)&&prob>0 && prob<1) + break; + printf("\nYou did not enter a valid probability.\n"); + }/*checks for invalid input*/ + prob*=10;/*makes prob a value between 1 and 9*/ + + srand(time(NULL)); /*initializes generator*/ + + int board[dim1][dim2]; + + for(int r=0; rboard[r][c]){ + printBoard[r][c] = ' '; + } + else printBoard[r][c] = '*'; + } + }/*fills in printableBoard*/ + + int count = 0; + for(int r=0; r