From 0a52bbcead9ecbb1930334c87d68aaaca9101af7 Mon Sep 17 00:00:00 2001 From: jwass91 Date: Tue, 26 Jul 2016 14:57:45 -0400 Subject: [PATCH 1/4] Added finished minesweeper --- minesweeper.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 minesweeper.c diff --git a/minesweeper.c b/minesweeper.c new file mode 100644 index 0000000..f4378f0 --- /dev/null +++ b/minesweeper.c @@ -0,0 +1,92 @@ +/* Jared Wasserman -- minesweeper.c */ +/*This program takes the dimensions of a grid from the user and a probalility for a mine to be in any given square. Then in returns the board for the end of the game.*/ +#include +#include +#include + +int main(){ + srand(time(NULL)); + int m; + int n; + float p; + + /*Getting And Checking Input*/ + int returnValue; + do{ + printf("Enter m dimension: "); + returnValue = scanf("%d",&m); + if(returnValue==0){ + printf("Invalid Input. "); + while(getchar()!='\n'); + } + }while(returnValue==0); + while(getchar()!='\n'); + do{ + printf("Enter n dimension: "); + returnValue = scanf("%d",&n); + if(returnValue==0){ + printf("Invalid Input. "); + while(getchar()!='\n'); + } + }while(returnValue==0); + while(getchar()!='\n'); + do{ + printf("Enter probalility (between 0 & 1): "); + returnValue = scanf("%f",&p); + if(returnValue==0||p<=0||p>=1){ + printf("Invalid Input. "); + while(getchar()!='\n'); + } + }while(returnValue==0||p<=0||p>=1); + + int p2=(100*p); + int arr[m][n]; + int x; + int y; + + /*Placing The Mines*/ + for(x=0;x(m-1)||sur[a][1]<0||sur[a][1]>(n-1)){ + /*Out of bounds*/ + }else{ + if(arr[sur[a][0]][sur[a][1]]==-1){ + count++; + } + } + } + arr[x][y]=count; + } + } + } + + /*Printing The Board*/ + for(x=0;x Date: Tue, 26 Jul 2016 18:12:10 -0400 Subject: [PATCH 2/4] Added hangman --- hangman.c | 256 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 hangman.c diff --git a/hangman.c b/hangman.c new file mode 100644 index 0000000..2702a96 --- /dev/null +++ b/hangman.c @@ -0,0 +1,256 @@ +/* Jared Wasserman -- hangman.c */ + +#include +#include +#include +#include +#include + +int memberq(char guessedLetters[],int size,char character){ + int guessed=0; + int x; + for(x=0;x0){ + return 1; + }else{ + return 0; + } +} + +int print(char word[],char guessedLetters[26],int numOfGuess,int incorrectGuesses){ + int i; + printf("\n"); + for(i=0;i Date: Wed, 27 Jul 2016 10:48:51 -0400 Subject: [PATCH 3/4] Fixed minor issues with hangman --- hangman.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hangman.c b/hangman.c index 2702a96..530e2ff 100644 --- a/hangman.c +++ b/hangman.c @@ -169,10 +169,10 @@ char input(char guessedLetters[26]){ }else{ while(getchar()!='\n'); while(1){ - printf("Enter you guess: "); + printf("Enter your guess: "); c = getchar(); if(isalpha(c)){ - if(memberq(guessedLetters,26,c)){ + if(memberq(guessedLetters,26,tolower(c))){ printf("You already guessed that character. "); while(getchar()!='\n'); }else{ @@ -196,8 +196,8 @@ int main(){ int numOfGuess=0; srand(time(NULL)); - char word[20]=""; - strcat(word,words[(rand()%11)]); + char word[20]="hello world"; + //strcat(word,words[(rand()%10)]); printf("\nWelcome To Hangman!\n"); printf("\nYou are trying to guess: \n"); From 646c3df3780d0c81f2f1bceb9a4d6fa6a72a902c Mon Sep 17 00:00:00 2001 From: jwass91 Date: Wed, 27 Jul 2016 10:57:37 -0400 Subject: [PATCH 4/4] fixed choosing word in hangman --- hangman.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hangman.c b/hangman.c index 530e2ff..566ec86 100644 --- a/hangman.c +++ b/hangman.c @@ -196,8 +196,8 @@ int main(){ int numOfGuess=0; srand(time(NULL)); - char word[20]="hello world"; - //strcat(word,words[(rand()%10)]); + char word[20]=""; + strcat(word,words[(rand()%10)]); printf("\nWelcome To Hangman!\n"); printf("\nYou are trying to guess: \n");